Suppose there are several tables that have similar fields (not necessarily the same name: title, name ...). It is necessary to make a sample of the type LIKE% ??%, so that in the end it is understood in which particular table the value is found.
That is, such a query displays all the rows found, but does not identify the table:
SELECT title, id AS id_1 FROM tbl_1 WHERE title LIKE %$txt% UNION SELECT title, id AS id_2 FROM tbl_2 WHERE title LIKE %$txt% That is, even if the first table is empty and the second is found, the result assigned to tbl_1 will be displayed:
[title] => xxx [id_2] => 123 For clarity:
http://sqlfiddle.com/#!2/126255/2/0
And I would like to see the result like this:
[title] => xxx [id_1] => null [id_2] => 123 [title] => xxxzzz [id_1] => null [id_2] => 456 [title] => wwwxxx [id_1] => 1212 [id_2] => null ...