Jump to content

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


GremlinP1R

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

Archived

This topic is now archived and is closed to further replies.

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