perfectDay
perfectDay

Reputation: 9

What's wrong with this query?

using MySQL version 4.0.27:

UPDATE `t` SET `col_x` = 
(SELECT `col_x` FROM `t` WHERE `col_y`='123456') WHERE `col_y`= '456789'

Error message: #1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'SELECT t FROM b WHERE col_x='1234

I tried LIKE '%123456%'

Upvotes: 0

Views: 127

Answers (3)

Matthew Jones
Matthew Jones

Reputation: 26190

Check out this page. Apparently you need to set your SQL mode to 'ANSI QUOTES'

Upvotes: -1

GSto
GSto

Reputation: 42350

You can't select and update from the same table in a query.

reference: mysql update documentation

Upvotes: 1

Michal M
Michal M

Reputation: 9480

I'm sorry to disappoint you, but subqueries are not supported in your version if MySQL.

Subqueries have been introduced in ver 4.1 according to MySQL Dev Zone

Upvotes: 3

Related Questions