mysql

getting nearest result within IFNULL

I've got a maintenance script which dumps a bunch of data from one db to another. I'm trying to get the data as SELECT id, IFNULL(rank1,(SELECT rank2 FROM table WHERE rank1 IS NOT NULL and rank2<rank2 of current row ORDER BY rank2 LIMIT 1)) FROM table What I'm attempting to get with the rank2 So, i believe I h...

MySql & PHP: How to find which row has an item in the leading spot in a CSV list?

This is kind of a weird question so my title is just as weird. This is a voting app so I have a table called ballots that has a two important fields: username and ballot. The field ballot is a VARCHAR but it basically stores a list of 25 ids (numbers from 1-200) as CSVs. For example it might be: 22,12,1,3,4,5,6,7,... And another one ...

Guid/Uuid in PHP with MySQL

I'd like to store uuids in the database as BINARY(16) but I need to accept them and present them as the XXXXXXXX-XXXX-XXXX-XXXX-XXXXXXXXXXXX format. Before I jump to split the guid in PHP code (what a fun that is!), are there any libraries or functions that do this out-of-the-box? ...

Need to Assess whether Joomla is good fit for Web Application Requirement

Hello, I have a web application that needs to be built using PHP/MySQL. The application will require documents to be generated from data in the MySQL database. Such documents will be printed and/or emailed and user will be prompted to run a daily print/email job based on business logic. This application functionality needs to be ma...

MySQL Identifier Question

From the mysql certification guide's example questions ... question Will the following SQL statement succeed or result in an error? Assume that the table to be created doesn't already exist. CREATE TABLE MD5 (id INT); answer The statement results in an error if the IGNORE_SPACE SQL mode is enabled. In that case, all function names...

Is there any way using which I can get Last Updated row Id

Hi All, Is there any way using which I can get the last row I have updated of the table. For Ex:- my table has 1000 records in it. I have updated the value of 500th record of table X. So, I want the ID 500 in return. Thanks in advance. Regards, ...

Uploading to a Remote Server

Hello all, I am working on a website, using PHP/MySQL, where users can upload videos, then, those videos are converted (using FFMPEG) to FLV and MP4 files. Now, the whole 'upload' and 'conversion' process takes place on a different (remote) server that is actually being hosted by a different provider. The reason I am using a differen...

mySQL query fails when read from file or web

This is driving me nuts! I have created a query. The query is written to Windows file for future connection to the remote database. Upon the connection using cURL, my local script uses cURL to send the query. I assemble variables using build_http_query. The cURL works just fine but the query fails. Every time. mySQL complains that qu...

Counting the particular field from table

Can I get the count results for particular field from table. for example im using this query, select id,retailer,email from tab i got the result set, 1 ret1 [email protected] 2 ret2 [email protected] 3 ret3 [email protected] 4 ret1 [email protected] 5 ret2 [email protected] 6 ret6 [email protected] What I need is count of (te...

Incorrect result for date comparison (to a timestamp column) in mysql

I've been having some 'strange' results while comparing dates. table1 has two rows with TIMESTAMPS values 2009-08-26 23:39:56 and 2009-08-27 00:01:42 When I make this query: select * from table1 c INNER JOIN table2 r ON r.table1_id = c.id WHERE DATE(c.authorization_date) = '2009-08-26' it returns both rows (when it only should have re...

How to delete a record?

Hi all, I have records in table1, if the records exist, it must copy into table2. I want to delete those records in a table1 once all the records are copied into another table2. Im still a beginner in database and with some researches, i found some tutorials on d internet how to connect with database, and the codes easy to understand so...

Complex SQL query, involving three tables and variable table names

I have two different tables from which I need to pull data blogs which has the following column blog_id and another table which has a variable name, like $blog_id . "_options Which has the following columns: option_id, option_name, option_value For example: option_id = 1, option_name='state', option_value='Texas' option_id =...

select in HQL (hibernate)

I have a table in mysql which has just on record. when I execute following hql query in netbeans HQL I got the following answer which is correct: query: from Customer as cust response: CustomerID PhoneNumber MainAddress SubAddress RequesstNumber Name 1 22334455 Niavaran shahrake naft 3 ...

Help with a SQL query

Hello, I have to perform a SQL query to get the top 10 albums according to number of views. The number of views is actually the sum of the views for each song in the specified album. My tables are: albums: - album_id - album_name - album_owner songs: - song_id - song_name - song_album - song_owner - song_views Can you guys help m...

Delete rows from two tables in one query

I have two tables: orders and orders_items. Both sharing the field orderID. I want to delete all rows from both tables where orderID=500, but I need to do this in only one query. Is this possible? ...

How can i benchmark my SQL and PHP code?

I have problems because i don't really know how I can test my code and sql ( mysql ) to see how long SQL queries and PHP functions /code take to run. Does anyone here know where I can find these tools? ...

View incoming query requests to MySQL server

Hi, is there a way we can view the incoming query requests to mysql server. I have a scenario where my asp.net application refuses to execute a query, but the same query executes inside of a mysql query browser. I have installed the mysql dotnet connector (5.0.9) via which I can conncet to the database. I have referred this page, but I ...

MySQL PHP incompatibility.

Ok maybe I've overlooked something really simple here, but I can't seem to figure this out. I'm running WAMP locally, but connecting to a remote MySQL database. The local version of PHP is the latest 5.3.0. One of the remote databases, being version 5.0.45 works fine. However, the other remote database I'm trying to connect to, which...

Writing a subquery using Zend DB

Hi I am having some problems turning the SQL below into a Zend Db query. $select = ' SELECT s.id, i.id as instance_id, i.reference, i.name, i.sic_code, i.start_date FROM sles s JOIN sle_instances i ON s.id = i.sle_id WHERE i.id = ( SELECT MAX(id) FROM sle_instances WHERE sle_id = s.id ) ORD...

using an aggregate function to narrow my query

I want to do something like this: SELECT locations.id, places.id, scannables.id, SUM(scannables.available) FROM `scannables` INNER JOIN places ON scannables.place_id = places.id INNER JOIN locations ON places.location_id = locations.id WHERE locations.id = 2474 AND scannables.bookdate BETWEEN '2009-08-27' and date_add('2009-08-27', IN...