How can you use mysql and the like/wildcard syntax across multiple tables, would it be as simple as:
(SELECT * FROM `table1` WHERE `name` LIKE '%tom%') AND (SELECT * FROM `table2` WHERE `name` LIKE '%sam%')
Not tested, just thinking about it.
How can you use mysql and the like/wildcard syntax across multiple tables, would it be as simple as:
(SELECT * FROM `table1` WHERE `name` LIKE '%tom%') AND (SELECT * FROM `table2` WHERE `name` LIKE '%sam%')
Not tested, just thinking about it.
Use UNION
(SELECT * FROM `table1` WHERE `name` LIKE '%tom%') UNION
(SELECT * FROM `table2` WHERE `name` LIKE '%sam%')
Actually if you use UNION, any duplicate rows may be removed. Use UNION ALL if you wish to retain any duplicates (say if you want to perform a COUNT on all rows matching %tom% in table1 and table2.
(SELECT * FROM `table1` WHERE `name` LIKE '%tom%') UNION ALL (SELECT * FROM `table2` WHERE `name` LIKE '%tom%')