phpretard Posted October 25, 2008 Share Posted October 25, 2008 I am searching my Database with the following query: $result = mysql_query("SELECT DISTINCT Email FROM Emails WHERE Email LIKE '%$list%' ORDER by Email "); Is there a way I can add more diverse searches such as: Right now I can serch everything containing the word "realty". What if I wanted to (in the same query) search for ONLY emails containg "realty" and "bank". How can I adjust this to perform such a serch? The form: <form name='sea' action='' method=post> <input type=text name=list size=30 /> <input type=submit name='GetList' value='search'> </form> Is this question clear? Thanks for your help! Quote Link to comment Share on other sites More sharing options...
JavaNinja Posted October 25, 2008 Share Posted October 25, 2008 $result = mysql_query("SELECT DISTINCT Email FROM Emails WHERE Email LIKE '%$list%' ORDER by Email "); How can I adjust this to perform such a serch? Use "AND" like so: <?php $result = mysql_query("SELECT DISTINCT Email FROM Emails WHERE Email LIKE '%$list%' AND Email LIKE '%$list2%' ORDER by Email ");?> Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.