mysql-insert

MySQL - A difficult INSERT...SELECT on the same table [MySQL 5.051]

I am trying to insert a new row into my table which holds the same data as the one I am trying to select from the same table but with a different user_id and without a fixed value for auto_id since that is an auto_increment field, and setting ti to NOW(). Below is my mockup query where '1' is the new user_id. I have been trying many vari...

How to do multiple MySQL INSERTs in a way that scales (PHP)

We have a loop in our PHP code which inserts rows into a table. e.g.: while ($info = mysql_fetch_assoc($someQuery)) { mysql_query("INSERT INTO X (i,j) VALUES ($info['ii'],$info['jj'])"); } This was fine a few months ago because the loop would only iterate several times. However, due to our website getting more traffic this loop no...

I'm trying to populate a MySQL table with some data, but, mysqli won't let me insert every 10th statement

I want to initialise a 'ticket' table with some ticket IDs. To do this, I want to insert 120 ticket IDs into the table. However, at every 10th statement, MySQL tells me that the ID already exists and thus won't let me insert it. Here's my code: //make a query $insert_ticket_query = "INSERT INTO ticket (id) VALUES (?)"; $inse...

Mysql "safe" merge

I have a table with incomplete field data in each of its rows that I want to fix. Here's an what I mean: mysql> CREATE TABLE test ( key INT a CHAR(1), b CHAR(1), c CHAR(1), ); mysql> CREATE TABLE test2 ( key INT a CHAR(1), b CHAR(1), c CHAR(1), ...

how do I insert a string datetime into mysql using c++

I have a datetime field in the following format: string date = "Jun 23 19:47:15 +0000 2010"; how do I insert it ito datetime field in mysql table? I am assuming I have to convert the date into unix timestamp before I insert it into the table. ...

MySQL Insert date log

I am trying to find out when something was added to a database I maintain but the script that adds the date was working. Is there a way to retrieve the date of the original INSERT command? ...