2011-11-11 12 views
0

以下のmysql全文検索でテーブル名を返す方法は?mySQL全文検索復帰テーブル名

(SELECT title,content,date 
FROM table1 
WHERE (MATCH 
(title,content) 
AGAINST 
('+$boolean' IN BOOLEAN MODE)) 
) UNION (
SELECT title,content,date 
FROM table2 
WHERE (MATCH 
(title,content) 
AGAINST 
('+$boolean' IN BOOLEAN MODE))) 
Order By date DESC 
LIMIT 0,10 

答えて

0
(SELECT 'table1' as table_name, title,content,date 
FROM table1 
WHERE (MATCH 
(title,content) 
AGAINST 
('+$boolean' IN BOOLEAN MODE)) 
) UNION (
SELECT 'table2' as table_name, title,content,date 
FROM table2 
WHERE (MATCH 
(title,content) 
AGAINST 
('+$boolean' IN BOOLEAN MODE))) 
Order By date DESC 
LIMIT 0,10 
0
(SELECT title,content,date, 'Table1' as TableName 
FROM table1 
WHERE (MATCH 
(title,content) 
AGAINST 
('+$boolean' IN BOOLEAN MODE)) 
) UNION (
SELECT title,content,date, 'Table2' as TableName 
FROM table2 
WHERE (MATCH 
(title,content) 
AGAINST 
('+$boolean' IN BOOLEAN MODE))) 
Order By date DESC 
LIMIT 0,10