user1397417
user1397417

Reputation: 738

what wrong with my mySQL query using REGEX and or operator?

I have a script that is generating queries like this one by grabbing categories and keywords from the database. However something is wrong with the syntax it seems. here is the code first:

UPDATE `mrhowtos_main`.`eng-jap` SET `category` = 'travel' WHERE `eng` REGEXP 'abroad|country|sight seeing|foreign|plane|train|bus' and where `category` REGEXP 'misc|none';

and here is the error returned by mySQL:

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 'where category REGEXP 'misc|none'' at line 1

I have looked at it for a long time and still dont seem to see what is wrong with it. im certain the error is not in the table or column names in the DB.

Upvotes: 0

Views: 136

Answers (1)

Tchoupi
Tchoupi

Reputation: 14691

The second where shouldn't be there. Try:

UPDATE `mrhowtos_main`.`eng-jap` SET `category` = 'travel' WHERE `eng` REGEXP 'abroad|country|sight seeing|foreign|plane|train|bus' and `category` REGEXP 'misc|none';

Upvotes: 2

Related Questions