MySQL Forums
Forum List  »  Newbie

Re: simple query
Posted by: Rick James
Date: November 21, 2016 06:27PM

You are still making up syntax, this time is how expressions are formed. This may appear to work, but it does not do what you think:

WHERE col = 'x' OR 'y' OR 'z'

You need

WHERE col = 'x' OR col = 'y' OR col = 'z'

Or you could say it:

WHERE col IN ('x', 'y', 'z')

The first one is parsed as

WHERE (col = 'x') OR ('y') OR ('z')

The risk is the ('y') treats the string 'y' as TRUE and selects more rows than you expect !

Options: ReplyQuote


Subject
Written By
Posted
November 21, 2016 05:23AM
November 21, 2016 05:37AM
November 21, 2016 05:51AM
Re: simple query
November 21, 2016 06:27PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.