Jump to content

Recommended Posts

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  :confused: )

 

$query = "SELECT * FROM listingsmanager_buyers WHERE buyers_ID AND listingBuyers_name LIKE '$queryString%' LIMIT 10";

Link to comment
https://forums.phpfreaks.com/topic/196326-help-with-one-query-syntax-please/
Share on other sites

$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";

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

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";

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

 

 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.