Jump to content

[SOLVED] multiple search query


jesushax

Recommended Posts

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

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%'

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

Archived

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

×
×
  • Create New...

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.