julio
julio

Reputation: 6728

mySQL check for column

I know how to check for the existence of a column using the syntax SELECT * FROM information_schema.COLUMNS WHERE TABLE_SCHEMA = "my_table" AND COLUMN_NAME = "my_column"

Is there a way to check for the existence of a column when the DB user doesn't have access to the information_schema? Or would you just do something like try a SELECT from that column and if you get an error then you know that the column doesn't exist?

Upvotes: 1

Views: 78

Answers (1)

Álvaro González
Álvaro González

Reputation: 146430

Good old SHOW COLUMNS FROM table_name:

Upvotes: 1

Related Questions