mojito Posted June 21, 2006 Share Posted June 21, 2006 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 Link to comment https://forums.phpfreaks.com/topic/12578-or-im-trying-to-find-a-field-which-has-a-or-b-or-c-in-it/ Share on other sites More sharing options...
cmgmyr Posted June 21, 2006 Share Posted June 21, 2006 The easiest way to do it is:[code]WHERE virtualName='stringone' OR virtualName='stringtwo' OR virtualName='stringthree'[/code] Link to comment https://forums.phpfreaks.com/topic/12578-or-im-trying-to-find-a-field-which-has-a-or-b-or-c-in-it/#findComment-48202 Share on other sites More sharing options...
fenway Posted June 23, 2006 Share Posted June 23, 2006 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. Link to comment https://forums.phpfreaks.com/topic/12578-or-im-trying-to-find-a-field-which-has-a-or-b-or-c-in-it/#findComment-48717 Share on other sites More sharing options...
cmgmyr Posted June 23, 2006 Share Posted June 23, 2006 O cool...didn't know you could do that.What do you know...you learn something new every day! Link to comment https://forums.phpfreaks.com/topic/12578-or-im-trying-to-find-a-field-which-has-a-or-b-or-c-in-it/#findComment-48777 Share on other sites More sharing options...
fenway Posted June 24, 2006 Share Posted June 24, 2006 [!--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\" /] Link to comment https://forums.phpfreaks.com/topic/12578-or-im-trying-to-find-a-field-which-has-a-or-b-or-c-in-it/#findComment-49018 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.