
Originally Posted by
Dr John
You can't search "maybe 5 - 10 MySQL tables", you have to specify the tables and the columns (attributes) in your search query.
Select attributes
from tablename
where attribute7 like 'fred%';
finds any occurrance in column attribute7 in tablename that starts with fred
Select attributes
from tablename
where attribute7 like '%fred%';
finds any occurence in the column attribute7 in tablename that has fred anywhere in it
Select attributes
from tablename
where attribute7 like '%fred';
finds any instance in column attribute7 in tablename that ends in fred
And if you want to search another table you then need a second query
Select otherAttributes
from otherTablename
where attribute2 like '%fred%';
and so on
you can NOT say the equivalent of "is fred anywhere in any of my tables"
Not necessarily true. You can search more than one table at once. You just need to specify what you want from each table...
Code:
SELECT a.fieldOne, a.fieldTwo, b.fieldOne
FROM TableOne as a, TableTwo as b
WHERE a.fieldOne LIKE "%one%"
OR b.fieldOne LIKE "%one%"
AND a.fieldTwo LIKE "%two%";
Bookmarks