Matei Gabriel Matei Gabriel - 5 months ago 38
MySQL Question

UPDATE syntax error for SET WHERE LIKE

UPDATE isc_products SET prodretailprice=145 WHERE prodcode LIKE TSACR3

I'm trying to update
for all the products that have
"TSACR3" but I keep getting this error:

#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 '[TSACR3]' at line 1

UPDATE `isc_products` SET `prodretailprice`=145 WHERE `prodcode` LIKE 'TSACR3'

Enclose the search pattern in single quotes.

LIKE syntax:

LIKE can be used with the following wildcard characters

  • % Matches 0 or more characters. E.g. LIKE 'TSACR3%' will match TSACR3 bla blah
  • _ Matches exactly one character. E.g. LIKE '_TSACR3' will match 2TSACR3 but NOT 42TSACR3