Jump to content

Archived

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

Radioactive Frog

searching more than one field

Recommended Posts

i have this query for searching one field

 


SELECT * FROM `hotels` WHERE hotelname LIKE \'%j%\'

 

at it works ok, but i would like to search say two more fields i thought it would be like below but that dont work :( please could someone point out where i am going wrong....thanks


SELECT * FROM `hotels` WHERE hotelname OR hotelcountry OR hoteladdress LIKE \'%j%\'

 

thanks

Share this post


Link to post
Share on other sites

more like this:

 

select * from hotels where \' *j%\' in (hotelname,hotelcountry,hoteladdress);

Share this post


Link to post
Share on other sites

sry the second * must be % ofcourse

 

this works on my system but I don\'t use phpadmin

Share this post


Link to post
Share on other sites


SELECT * FROM hotels WHERE hotelname LIKE \'%j%\' OR hotelcountry LIKE \'%j%\' OR hoteladdress LIKE \'%j%\' 

 

and make sure that the data in mysql table is all lowercase, cuz you are using \"j\".

 

goodluck

Share this post


Link to post
Share on other sites

great that works for that, but what about if i had to search variables coming in? how would i incorporate that? i have tried a couple of things but they dont work :(

 

any ideas?

 

thanks again

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.