Поиск полнотекстового объединения MySQL возвращает имя таблицы

#mysql

#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
  

Ответ №1:

 (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
  

Ответ №2:

 (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