Reputation: 1
I am new to mysql, while executing this query it updates the column value as 0:
UPDATE table_name set column_name='some_value ' AND same_column_name='different_value'
I am not getting any error while using AND in UPDATE Statement in my PHP program.
Upvotes: 0
Views: 127
Reputation: 1936
Your SQL syntax is wrong, the correct syntax should be separated by comma
Your statement is actually update Column_name to the AND result of 'some_value' and same_column_name='different_value
UPDATE table_name set column_name='some_value ', same_column_name='different_value'
Upvotes: 1
Reputation: 5697
It's interpreting your expression as a Boolean then saving it as an int.
column_name='some_value ' AND same_column_name='different_value'
is false, probably then converted to int with value of zero.
More MySQL idiocy.
Upvotes: 1