Saranya Sara
Saranya Sara

Reputation: 1

Why am i get 0 while execute the query in MySQL?

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

Answers (2)

Jacob
Jacob

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

LoztInSpace
LoztInSpace

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

Related Questions