I’m using a union query:
SELECT snippet_id, title FROM tbl_snippets WHERE title LIKE ?
UNION
SELECT tag_id, tag FROM tbl_tags WHERE tag LIKE ?
UNION
SELECT category_id, category FROM tbl_categories WHERE category LIKE ?
How will I know which table a result came from?snippet_id, tag_id and category_id doesn’t have a prefix like SN, TG, or CI that I could use to determine where a result came from.
The results are basically put together in one result so I don’t really know if what I’m thinking is possible that’s why I came asking here.
Why not adding the prefix as a separate (computed) column?
Edit: I have also changed
UNION [DISTINCT]toUNION ALL– for the following reasons:UNIONandUNION ALL, introducing the prefix will change the number of result rows.UNION ALLis slightly faster thanUNION DISTINCT.UNION ALL.