Jump to content

Searching mysql database for 2 variables


boyx

Recommended Posts

I have a database that i can search for one variable,
now i would like it to match a first variable and a second in order to return a result,

II have this at the moment:

[code]$query = "SELECT *
       FROM  `pbx`
       WHERE  `swlevel` LIKE '$keyword%' AND `vm`='$keyword2%'";
[/code]

So keyword one checks swlevel and keyword 2 checks vm entry
problem is it seems to return mixed results,

I have one which is 23 and yes
and one that is 24 and none, but it returns both rows as valid results ...

Any hints or ideas? just getting used to this stuff.
Link to comment
Share on other sites

In my clients table, i have two clients whose company name contains 'afon'.

So, if i were to run: "SELECT * FROM clients WHERE company LIKE '%afon%'" it would return two results.

However, if i run: "SELECT * FROM clients WHERE company LIKE '%afon%' AND client_id = '2'" this will return only the one result.

This does work... as i am using it right now.
Link to comment
Share on other sites

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.