So I’m writing a script that can hopefully populate my database with new values. The data has a one to one correspondance by the order they’re in. The data are stored inside of an array in PHP. So the first row will map to the first element that I have, second row and second data, and so on.
I’m planning on just echo’ing it and piping the sql ALTER statement from the command prompt. So my question is, how can I ALTER a row by adding/changing new data to a certain column without knowing the ID. All I have is the 1 to 1 correspondance in the order that they’re in.
Thanks, any help is much appreciated.
EDIT:
| id | key | name | address
+-----+-----------------------------------+--------------------+----------------
| 1 | quests_buildloggingcamp_type | Build |
|
| 3 | quests_buildquarry_type | Build |
So I have this data in another document.
1. 394 cakeville road.
2. 2912 mark street.
3. more addresses...
I want to add the first address to the first row (id = 1), and second address to second row (id = 3). I can increment the ID each time, but because I’ve deleted a row, ID=2 is missing, I want to add them correctly without skipping any addresses because I have the same amount of rows as addresses.
If you have a
PRIMARY KEYorUNIQUE KEYon a table then something like this will work for you:e.g. If you have a
UNIQUE KEYon columnathen do:For syntax and examples visit here
EDIT: try this query inside you loop inside script for updating every record to next row:
Outside loop for one time:
Inside loop: