How to select a column name in Mysql?

Asked

Viewed 1,192 times

1

How to take the name of a column in Mysql even if it has no lines?

  • 1

    Please don’t write in high box.

1 answer

2


show columns from nome_da_tabela

It is simpler, this 'query' returns six fields field (what matters to you), type, null, key, default and extra.

For details use the information_schema.Columns

SELECT * FROM information_schema.columns WHERE table_name = 'nome_da_tabela'
  • there is no way to do this with select no

  • Because I didn’t want to do two layers on the bench

  • @George u want to take the column names by the array that the database returns? would that be it?

  • This guy has like

  • @George without result does not have pq it returns an empty array. You can make a check if returned empty executes the reply query.

  • 1

    guy worked out here

  • I used show Columns from table name_a_name and set a condition

  • when select is vario it calls show Columns from tableName

Show 3 more comments

Browser other questions tagged

You are not signed in. Login or sign up in order to post.