I want to select column names, but I do not know the table structure in advance, and this can change, so I can’t just hardcode the select statement with the column names. I also DO NOT want to select each column. Is there an easy way to do this?
My thoughts are some combination of these two queries, but my SQL is not so good.
SHOW COLUMNS FROM table_name;
SELECT * FROM table_name;
I tried using extra select, but that didn't work. Nothing seems to be happening, I am not getting an error. I just do not get results.
SELECT (SELECT column_name
FROM information_schema.columns
WHERE table_name ='table_name')
FROM table_name;
Maybe I need to connect? .. Anyway, any help would be great, thanks
source
share