jonnypixel Posted March 24, 2010 Share Posted March 24, 2010 Hi, I am wanting to live search by either buyers ID or buyers name But when i try to add buyers name to the query it wont work. I have tried seperating filed names with a comma and also tried (field1,field2) But dosent seem to work. Im just trying to figure out how i can change this:: $query = "SELECT * FROM listingsmanager_buyers WHERE buyers_ID LIKE '$queryString%' LIMIT 10"; To something like this:: ( but actually one that works ) $query = "SELECT * FROM listingsmanager_buyers WHERE buyers_ID AND listingBuyers_name LIKE '$queryString%' LIMIT 10"; Quote Link to comment https://forums.phpfreaks.com/topic/196326-help-with-one-query-syntax-please/ Share on other sites More sharing options...
xcandiottix Posted March 24, 2010 Share Posted March 24, 2010 $query = "SELECT * FROM listingsmanager_buyers WHERE buyers_ID AND listingBuyers_name LIKE '$queryString%' LIMIT 10"; did you try $query = "SELECT * FROM listingsmanager_buyers WHERE buyers_ID & listingBuyers_name LIKE '$queryString%' LIMIT 10"; ? I haven't seen AND used in a SELECT command string before. or you may want to narrow it down with separate vars? $query1 = "SELECT * FROM listingsmanager_buyers WHERE buyers_ID LIKE '$queryString%' LIMIT 10"; $query2 = "SELECT * FROM listingsmanager_buyers WHERE listingBuyers_name LIKE '$queryString%' LIMIT 10"; Quote Link to comment https://forums.phpfreaks.com/topic/196326-help-with-one-query-syntax-please/#findComment-1030913 Share on other sites More sharing options...
jonnypixel Posted March 24, 2010 Author Share Posted March 24, 2010 Sweet, Thankyou! I will try both your suggestions and most prob go for the 2 query solution. I am only new so i am trying AND but obviously it wont work if it cant be used in that context. oops! Thanks again, really appreciate that. John Quote Link to comment https://forums.phpfreaks.com/topic/196326-help-with-one-query-syntax-please/#findComment-1030914 Share on other sites More sharing options...
PFMaBiSmAd Posted March 24, 2010 Share Posted March 24, 2010 You want to find records where buyers_ID is like $queryString or listingBuyers_name is like $queryString? $query = "SELECT * FROM listingsmanager_buyers WHERE buyers_ID LIKE '$queryString%' OR listingBuyers_name LIKE '$queryString%' LIMIT 10"; Quote Link to comment https://forums.phpfreaks.com/topic/196326-help-with-one-query-syntax-please/#findComment-1030915 Share on other sites More sharing options...
xcandiottix Posted March 24, 2010 Share Posted March 24, 2010 It seems he's got a search that says "Enter your ID or Name" and it's trying to search accordingly doesn't it? Quote Link to comment https://forums.phpfreaks.com/topic/196326-help-with-one-query-syntax-please/#findComment-1030918 Share on other sites More sharing options...
jonnypixel Posted March 24, 2010 Author Share Posted March 24, 2010 Hi again, It seems there is more than one way to skin a cat... Thankyou to xcandiottix and PFMaBiSmAd I tried both methods and it seems that PFMaBiSmAd skinned the cat this time. Thankyou again to both of you champions for your willingness to help. John Quote Link to comment https://forums.phpfreaks.com/topic/196326-help-with-one-query-syntax-please/#findComment-1030920 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.