I've googled pretty hard on this topic but didn't manage to find anything relevant.
MySQL question: is it possible to display the database that holds the table row in a select query?
For example, I have 3 databases each with the same structure. I run something like this:
select database(), id, name, created_on from (
select * from db1.user
union all
select * from db2.user
union all
select * from db3.user) as q where id = "123";
In this case, the database()
refers to the current database that the query is being run from. I want to change it to show the database name that's holding the row and table instead (db1
,db2
or db3
)
I am not sure if this is possible so I'm hoping someone will have a clue on this. Thanks!