Radioactive Frog Posted December 18, 2003 Share Posted December 18, 2003 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 Link to comment https://forums.phpfreaks.com/topic/1522-searching-more-than-one-field/ Share on other sites More sharing options...
Tmic Posted December 18, 2003 Share Posted December 18, 2003 more like this: select * from hotels where \' *j%\' in (hotelname,hotelcountry,hoteladdress); Link to comment https://forums.phpfreaks.com/topic/1522-searching-more-than-one-field/#findComment-5001 Share on other sites More sharing options...
Radioactive Frog Posted December 18, 2003 Author Share Posted December 18, 2003 that doesnt show any results when i test it in phpmyqdmin Link to comment https://forums.phpfreaks.com/topic/1522-searching-more-than-one-field/#findComment-5003 Share on other sites More sharing options...
Tmic Posted December 18, 2003 Share Posted December 18, 2003 sry the second * must be % ofcourse this works on my system but I don\'t use phpadmin Link to comment https://forums.phpfreaks.com/topic/1522-searching-more-than-one-field/#findComment-5005 Share on other sites More sharing options...
Radioactive Frog Posted December 18, 2003 Author Share Posted December 18, 2003 yeah i had changed that, sorry i should have saidm but it doesnt make any difference Link to comment https://forums.phpfreaks.com/topic/1522-searching-more-than-one-field/#findComment-5007 Share on other sites More sharing options...
nabeel21 Posted December 18, 2003 Share Posted December 18, 2003 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 Link to comment https://forums.phpfreaks.com/topic/1522-searching-more-than-one-field/#findComment-5008 Share on other sites More sharing options...
Radioactive Frog Posted December 18, 2003 Author Share Posted December 18, 2003 thanks i will try it, j is only a test to see if it works i will put a \'%$search%\' there when i put it on the php page !! thanks again Link to comment https://forums.phpfreaks.com/topic/1522-searching-more-than-one-field/#findComment-5009 Share on other sites More sharing options...
Radioactive Frog Posted December 18, 2003 Author Share Posted December 18, 2003 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 Link to comment https://forums.phpfreaks.com/topic/1522-searching-more-than-one-field/#findComment-5013 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.