2012-03-11 170 views
0

如何獲取輸出或查詢行所在的表。 我需要知道輸出行包含哪個表。MySQL聯盟輸出查詢

sprinf(SELECT id,alias,title,id_category FROM blog_article 
UNION 
SELECT id,alias,title,id_category FROM forum_thread 
WHERE LOWER(title) LIKE '%s%%' LIMIT 5, $key); 
+0

分配行表 – 2012-03-11 15:49:11

回答

0
sprinf(SELECT "blog_article" as tbl,id,alias,title,id_category FROM blog_article 
UNION 
SELECT "forum_thread" as tbl,id,alias,title,id_category FROM forum_thread 
WHERE LOWER(title) LIKE '%s%%' LIMIT 5, $key); 

的行將要麼blog_article或forum_thread爲第一場「TBL」,從中可以找出行來到該表從