Jump to content

PHP Searching for one field in more than one table....


Recommended Posts

Hi There All.

I'm doin a script with an advance search function but are batteling to get working. Every thing are working 100% except this one field. In the data base I have a Company1 - Company0 thats equil to Company10.
Now for my search I need to search for a spesific field in all ten tables, or must I call them rows?
Okay this is what I have.....

// Get all the data from the "Users" table
  if ($select == Company){$result = mysql_query("SELECT * FROM individuals WHERE Company* LIKE ('%$for%') AND `Active` = 0 ORDER BY Surname ASC ");}
  else {
  $result = mysql_query("SELECT * FROM individuals WHERE $select LIKE ('%$for%') AND `Active` = 0 ORDER BY Surname ASC ");}

There on the first line is my problem, where it says Company*, Now I have treid making it % and I have treid to put in more than one but then I just get errors! Can any one please help!
As far as I'm aware you can't use '*' wildcards for column names in a 'where' clause... use 'or'

[code]
"SELECT * FROM individuals WHERE Company1 LIKE ('%$for%') OR Company2 LIKE ('%$for%') OR Company3 LIKE ('%$for%')...
[/code]

Regards
Huggie
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.