mysql

Expression engine! MySQL query for entry/expiration date range

I’ve built a site in ExpressionEngine for some holiday apartments (EE1.6.8), that uses two related weblogs for bookings. ‘apartments’ & ‘booking’ Bookings are set up as weblog entries using the entry_date for arrival and expiration_date for leaving date, and are related back to the apartment that is booked. I’ve built a page that list...

Saving a .xls file with fwrite

hi guys, I have to create a script that takes a mySQL table, and exports it into .XLS format, and then saves that file into a specified folder on the web host. I got it working, but now I can't seem to get it to automatically save the file to the location without prompting the user. It needs to run every day at a specified time, so it ...

Selecting all object for which not exists value

I have two tables: object that has object_id column and avalues that have object_id (FK for object.object_id) and value_type (for simplicity I ommited other columns). I want to select all objects that don't have values with specified type. My select looks like this: SELECT object_id FROM object WHERE NOT EXISTS (SELECT true FROM avalue...

MySQL and Matlab

I want to interact with a MySQL database from Matlab. I found a mysql "library" for matlab here and the same on mathworks. I followed the instructions to compile the library and the compilation seems to be successful. I get a mex32 file at the end. Only, the instructions on the first page refer to a Dll that I need to use (I guess that ...

MySQL: Check if first character is _not_ A-Z

I have to create an SQL Query to get all rows starting with a specific character, except if the parameter passed to the (PHP) function is 0, in that case it should get every row that does not start with A - Z (like #0-9.,$ etc). What is the easiest and fastest way to get those rows? DB: MySQL 5.1 Column: title ...

Alternative to 'where col in (list)' for MySQL

Hi I have the following table T: id 1 2 3 4 col a b a c I want to do a select that returns the id,col when group by(col) having count(col)>1 One way of doing it is SELECT id,col FROM T WHERE col IN (SELECT col FROM T GROUP BY(col) HAVING COUNT(col)>1); The intern select (from the right) returns 'a' and m...

Passing object from PHP to Mysql Stored procedure

Hi All, Scenario :- I have to call MYSQL stored procedure from PHP and do some operations ( around 15 commands ) on the database Problem :- I have to call stored procedure with 36 parameters. Lot of parameters . I don't think it is a good idea to pass these many individual parameters and even heard passing individul parameters increase...

Method to sort MYSQL results by an arbitriary letter (ie, show all rows starting with F first)

I have a column of states, and, depending on the query, I want to order by results by a particular state, then by id (Asc or Desc, depending). For instance, I might want to show all rows with state "HI", sorted by ID desc, and then all the other rows, sorted by id desc. I was hoping I could do this in one query, rather than getting all...

how to specify only start index in LIMIT in MySQL select query?

I want to select the records from the table starting from 3rd row. How this can achieved with LIMIT? ...

Is the time cost constant when bulk inserting data into an indexed table?

I have created an archive table which will store data for selecting only. Daily there will be a program to transfer a batch of records into the archive table. There are several columns which are indexed; while others are not. I am concerned with time cost per batch insertion: - 1st batch insertion: N1 - 2nd batch insertion: N2 - 3rd b...

MySQL alias shorthand?

Hi, I need to select all columns from two tables, but need to be able to differentiate between them in the result. Is there a shorthand method of giving each column in the result an alias? For example: SELECT t1.* AS t1.SOMETHING , t2.* AS SOMETHING_ELSE FROM TABLE1 INNER JOIN TABLE2 ON SOMETHING = SOMETHING_ELSE In ...

How to order by results from 2 separate tables in PHP and MySQL.

I am trying to output results of 2 sql queries to one JSON file. The problem is that I would like to order them ascending by distance which is the result of equation that takes homelat and homelon from the users table and lat, lng from locations table.(basically it takes lattitude and longitude of one point and another and computes the d...

How to determine which my.cnf mysql is using

Hello, Is there a way I can figure out which my.cnf mysql is currently using? The reason is because it's using the correct socket file to connect, but I can't figure out exactly which (if any) my.cnf it's using or trying to use so I can manually set the correct path on my local machine. ...

MySQL Query : Advise Needed.

"SELECT id as Id from dbTable WHERE code = ? AND CURDATE() BETWEEN start_date AND end_date AND offerId IN ('12321', '12124')"; //Passing arguments for the query $args = array_merge(array(51342),$offerid); //Execute the prepared query $statement->execute($args); Now array(51342) represents combination of code+value, aside my database ...

Query MSQL for winners, starting at xth place using SELECT

In my MySQL table Winners, I have a list of people who have won. What I'd like to do is select a list of the names of 10 winners. So what I have right now is this: SELECT name FROM Winners ORDER BY points DESC LIMIT 10 This returns the first 10 winners which is great. But how can I make it (for example) return 10 winners, but starti...

How to concat datatypes like integers(integer with integer) & varchar(varchar with varchar) in mysql ?

How can we concat integers with integers varchar with varchar int with varchar in MySQL ? ...

MySQL User AutoIncrement Permissions Restriction

I have two databases that need to have their auto increment ids on various tables synced. Right now, I have a PHP function that checks the current auto increment id for both tables and then sets the lowest to the highest. If there is a better way to do this, I'm all ears. I really don't want to give the web user alter permissions, as a ...

Migrate from Oracle to MySQL

We ran into serious performance problems with our Oracle database and we would like to try to migrate to a MySQL-based database (either MySQL directly or, more preferrably, Infobright). The thing is, we need to let the old and the new system overlap for at least some weeks if not months, before we actually know, if all features of the n...

Dumping views with mysqldump in the right order.

I have a script that backs up our database, which contains multiple tables and views constructed from tables. The command used is: mysqldump -u UserName -ppassword -h hostname DatabaseName > dump.sql; I have noticed however that some view definitions are backed up before the definitions of the tables. This causes an issue when restor...

Generating SQL script from MySQL database table

Hi, Is there any application that will read a MySQL database table and generate a SQL script of INSERT statements (so that I can copy tables from one db to another db)? OR how can I transfer content from db1.table1 to db2.table2 where table1 and table2 is same. Thank you. ...