jesushax Posted July 10, 2008 Share Posted July 10, 2008 hi below is my sql statment ive probably done the whole thing wrong but could someone tell me how i do a LIKE and multiple WHERE'S in a statement? Cheers $SQL = mysql_query ("SELECT * FROM tblDirectory WHERE CompanyName LIKE '%$CompanyName%' AND WHERE THS='$Heating' AND WHERE TJoiner='$Joiner' AND WHERE TPlumb='$Plumber' AND WHERE TGeneral='$General' AND WHERE TFloor='$Floor' AND WHERE TPlaster='$Plaster' AND WHERE TSan='$San' AND WHERE TPlant='$Hire' AND WHERE TCeramic='$Tiler' AND WHERE TStore='$Store' AND WHERE TElec='$Elec'") or die (mysql_error()); Link to comment https://forums.phpfreaks.com/topic/114054-solved-multiple-search-query/ Share on other sites More sharing options...
waynew Posted July 10, 2008 Share Posted July 10, 2008 Here: Will give you all names that have whatever characters/words AND THEN john. WHERE name like '%john' Will give you every name that starts with John WHERE name like 'john%' Will give you every name that has the word john in it regardless of what words/characters come before or after. WHERE name like '%john%' Link to comment https://forums.phpfreaks.com/topic/114054-solved-multiple-search-query/#findComment-586216 Share on other sites More sharing options...
waynew Posted July 10, 2008 Share Posted July 10, 2008 My bad. I read your question wrong. Link to comment https://forums.phpfreaks.com/topic/114054-solved-multiple-search-query/#findComment-586217 Share on other sites More sharing options...
jesushax Posted July 10, 2008 Author Share Posted July 10, 2008 yeah i kinda already knew that but thanks for offering input though Cheers Link to comment https://forums.phpfreaks.com/topic/114054-solved-multiple-search-query/#findComment-586220 Share on other sites More sharing options...
jesushax Posted July 10, 2008 Author Share Posted July 10, 2008 anyone help? Link to comment https://forums.phpfreaks.com/topic/114054-solved-multiple-search-query/#findComment-586264 Share on other sites More sharing options...
rajivgonsalves Posted July 10, 2008 Share Posted July 10, 2008 what exactly your trying to achieve, why you want multiple wheres just use the "AND" instead of "AND WHERE" Link to comment https://forums.phpfreaks.com/topic/114054-solved-multiple-search-query/#findComment-586266 Share on other sites More sharing options...
jesushax Posted July 10, 2008 Author Share Posted July 10, 2008 ive managed to do it, figured it out $SQL = mysql_query ("SELECT * FROM tblDirectory WHERE THS='$Heating' AND TJoiner='$Joiner' AND TPlumb='$Plumber'AND TGeneral='$General' AND TFloor='$Floor' AND TPlaster='$Plaster' AND TSan='$San' AND TPlant='$Hire' AND TCeramic='$Tiler'AND TStore='$Store'AND TElec='$Elec' AND CompanyName LIKE '%$CompanyName%'") or die (mysql_error()); Cheers though Link to comment https://forums.phpfreaks.com/topic/114054-solved-multiple-search-query/#findComment-586267 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.