Well if you are looking to update information then you could use either the "UPDATE ... WHERE" syntax or the "REPLACE [INTO] ... WHERE" syntax.
See [mysql_man]REPLACE[/mysql_man] And [mysql_man]UPDATE[/mysql_man] for more information
eg,
Code: Select all
REPLACE INTO `yourTableName` SET `column1`='column1_value', `column2`='column2_value` WHERE `primaryKey`='primaryKeyValue';
The above will delete the row if a match is found, then insert the new data. (Note that the old data is removed first so if you don't change every column then you end up with blank columns).
You can also use the UPDATE syntax:
Code: Select all
UPDATE `tableName` SET `column1`='column1Value', `col2`='col2_value'
This will update the ENTIRE table's columns column1 and col2 to the values you specify in the statement.
If you want to update only one column for a particular record then you must give a restriction (WHERE foo = bar) eg
Code: Select all
UPDATE `tableName` SET `column1`='column1_value' , `col2`='col2_value' WHERE `thisPrimaryKey`='thisExactValue';
That will update the table `tableName` setting the columns column1 and col2 to the values specified only where the match is found.
Note with either of the two queries you can have more than (or less than) two `col`='value' sets
eg
Code: Select all
UPDATE `tableName` SET `column1`='column1_value' , `col2`='col2_value' , `col3`='value' , `col4`='value' WHERE `thisPrimaryKey`='thisExactValue';
or
UPDATE `tableName` SET `column1`='column1_value' WHERE `thisPrimaryKey`='thisExactValue';