Skip to content
Advertisement

How to select a column from the output of ‘SHOW COLUMNS’ sql

I am using the sql command SHOW COLUMNS in this way

It outputs multiple columns, specifically one called ‘COLUMN_NAME’ that I would like to select.

I tried doing

which gives an error, is there another way I can just show one of the columns of the output? Is this because the output is not a table so I cannot query from it?

Advertisement

Answer

You can use the like function:

There are limitations on using the output of the show command, so an alternate approach is to use the INFORMATION_SCHEMA.

If you need to query the results of a show command, you can use the result_scan table function:

Remember to double quote the column names produced by the show command. It’s a metadata result and the column names are lower case.

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