I need to perform a search across 18 separate SQL tables for a string. The search will be looking in differently named fields and multiple fields on some tables.
While I can achieve this with something like the below (the first 2 tables), I feel the code is going to get very unwieldy once all 18 tables are joined.
Is there any way I can refine this code?
Also when the result is given can I find out with PHP which table the answer came from?
mysql_query("SELECT a.about,b.title,b.article,b.description
FROM about a
JOIN articles b ON b.user=a.user
WHERE (upper(a.about) LIKE'%".$val."%') OR (upper(b.title) LIKE'%".$val."%') OR (upper(b.article) LIKE'%".$val."%') OR (upper(b.descirption) LIKE'%".$val."%') ORDER BY $order $max");