0

Hi!

I'm looking to update a field in a table via PHP, basically asking it to change a fields contents to 'foo' if it currently contains the word 'bar', or to change its contents to 'key' if it currently contains the word 'board'. I can't seem to get the syntax right, though.

Can someone assist me with correcting my syntax? My query is below:

mysql_select_db($database_TheBoard, $TheBoard);
$correct_columnname = "UPDATE tablename SET columnname='foo' WHERE columnname ='bar' AND columnname='key' WHERE columnname ='board'";
$Result_correct_columnname = mysql_query($correct_columnname, $TheBoard) or die("Unable to correct columnname: ".mysql_error());

Thanks!

2
Contributors
2
Replies
3
Views
8 Years
Discussion Span
Last Post by jay.barnes
0

If you are trying to update the same column to different values on different conditions, then you'll have to use two separate queries.

0

If you are trying to update the same column to different values on different conditions, then you'll have to use two separate queries.

I was afraid that might be the answer, but I think I can find a way to work around my situation elsewhere. Thanks for your time!

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.