To the other answers that are posted about SHOW COLUMNS and the information scheme. The OP clearly said: " I know there are other ways to get the column names from the table , but I want to know if this is possible with some sort of SELECT query."
Learn to read.
In any case, to answer your question; No, you canβt. You cannot select a row from an empty table. Even a row with empty values ββfrom an empty table.
However, for this you can apply the trick.
Create an additional table called 'dummy' with one column and one row in it:
Table: dummy
dummy_id: 1
It's all. Now you can make a select clause as follows:
SELECT * FROM dummy LEFT OUTER JOIN your_table ON 1=1
This will always return a single row. However, it does contain a dummy_id column. However, you can simply ignore this, and do whatever you like with the (empty) data.
So this is just a trick to do this with the SELECT statement. There is no default way to do this.
source share