Answer by Ike Walker for Mysql union clause identify tables
The problem is the backticks you have around the 'table-name' AS 'cat'. Backticks are for quoting table and column names, not strings. You should use single quotes instead: (SELECT *, '2' AS 'cat' from...
View ArticleAnswer by Kermit for Mysql union clause identify tables
Use UNION ALL instead of UNION.(SELECT *, `2` AS 'cat' from `2` where `recid` = 'cneta0ld00ah') UNION ALL(SELECT *, `3` AS 'cat' from `3` where `recid` = 'cneta0ld00ah') UNION ALL(SELECT *, `4` AS...
View ArticleAnswer by podiluska for Mysql union clause identify tables
Do all the tables have the same structure? In a Union, with select *, they need to.If so, try removing the bracketsSELECT recid, item, `2` AS `cat` from `2` where `recid` = 'cneta0ld00ah'UNION SELECT...
View ArticleMysql union clause identify tables
I have a mysql table which holds lots of data across multiple tables. So to get it all out, I think the best bet is to use a UNION clause, however I also want to know which table the results come from...
View Article