Skip to content
Advertisement

How do I get column names of two tables at a time

How do I get the column name of two tables in a single query ?

This works for single table. But if I try

This throws error.

Advertisement

Answer

Different queries will be put together using UNION ALL (or UNION only if it’s necessary to exclude identic values which appear in both queries):

Since you want to get data from the same table, you don’t need two queries at all.

Just use an IN clause…

…or use OR:

User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement