user456137
user456137

Reputation: 97

'AND' in mysql update query

I ran the following query on mysql by mistake, and mysql ran it without error:

UPDATE table SET col1='value1' AND col2='value2' WHERE ID='id'

Thie query should have been

UPDATE table SET col1='value1', col2='value2' WHERE ID='id'

So my question is: what did the first query with the 'AND' actually do? It seemed to set col1='0' for some reason, which seems strange. Is this just a bug or is this really a valid query?

Upvotes: 4

Views: 58

Answers (1)

Karolis
Karolis

Reputation: 9562

This is what the query actually did:

UPDATE table SET col1=('value1' AND col2='value2') WHERE ID='id'

Upvotes: 3

Related Questions