GremlinP1R Posted October 10, 2006 Share Posted October 10, 2006 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! Link to comment https://forums.phpfreaks.com/topic/23512-php-searching-for-one-field-in-more-than-one-table/ Share on other sites More sharing options...
HuggieBear Posted October 10, 2006 Share Posted October 10, 2006 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]RegardsHuggie Link to comment https://forums.phpfreaks.com/topic/23512-php-searching-for-one-field-in-more-than-one-table/#findComment-106698 Share on other sites More sharing options...
GremlinP1R Posted October 10, 2006 Author Share Posted October 10, 2006 Oh Thanx HuggieBear.Your a life saver, Have treid or but done it the wrong way. But its working now thanx!Regards Gremlin Link to comment https://forums.phpfreaks.com/topic/23512-php-searching-for-one-field-in-more-than-one-table/#findComment-106701 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.