MySQL row with table name

I want to ask how to show the table name along your data. For example, I have 2 tables.

TV show

id (int) title (varchar) release_date (date) 

Films

 id (int) title (varchar) release_date (date) 

I would like to display

 id title release_date table_name 

So the question is how to display table name data. Thanks:)

+4
source share
1 answer

Just try:

 SELECT id, title, release_date, 'TV shows' as table_name FROM `TV shows` UNION ALL SELECT id, title, release_date, 'Movies' as table_name FROM `Movies` 
+6
source

Source: https://habr.com/ru/post/1484591/


All Articles