Jump to content

Archived

This topic is now archived and is closed to further replies.

mojito

"OR" im trying to find a field which has a or b or c in it

Recommended Posts

Im trying to look in a single field for theoccurance of one of three strings..looking at an operator page on mysql.com i see that to get [b]or[/b] you just use a space so
[code]
....WHERE virtualName='stringone stringtwo stringthree'
[/code]

I would like to get a hit if the field contains either "stringone" or "stringtwo" or "stringthree"

thanks for any help.

mojito

Share this post


Link to post
Share on other sites
The easiest way to do it is:
[code]WHERE virtualName='stringone' OR virtualName='stringtwo' OR virtualName='stringthree'[/code]

Share this post


Link to post
Share on other sites
Actually, IMHO, an IN clause is "easier":

[code]WHERE virtualName IN ( 'stringone', 'stringtwo', 'stringthree' )[/code]

Not to mention that it makes the conversion from an array trivial... plus I'm sure the optimizer has less work to do.

Share this post


Link to post
Share on other sites
O cool...didn't know you could do that.


What do you know...you learn something new every day!

Share this post


Link to post
Share on other sites
[!--quoteo(post=387154:date=Jun 23 2006, 09:37 AM:name=cmgmyr)--][div class=\'quotetop\']QUOTE(cmgmyr @ Jun 23 2006, 09:37 AM) [snapback]387154[/snapback][/div][div class=\'quotemain\'][!--quotec--]
O cool...didn't know you could do that.
What do you know...you learn something new every day!
[/quote]
I wish that was actually true.... [img src=\"style_emoticons/[#EMO_DIR#]/laugh.gif\" style=\"vertical-align:middle\" emoid=\":laugh:\" border=\"0\" alt=\"laugh.gif\" /]

Share this post


Link to post
Share on other sites

×

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.