sql - Display ALL the columns from table that doesn`t contain the Primary Keys -


i`ve got query do. display columns table named 'somehow' not primary keys.

this how trying obtain column headers differ primary key id column :

select cols.column_name  information_schema.table_constraints t  join information_schema.key_column_usage k  using(constraint_name,table_schema,table_name) t.constraint_type <> 'primary key'  , t.table_schema='mydb'  , t.table_name='somehow'  

something not right since sql error. doing wrong?

update :

select k.column_name  information_schema.table_constraints t  join information_schema.key_column_usage k using(constraint_name,table_schema,table_name) t.constraint_type <> 'primary'  , t.table_schema='mydb'  , t.table_name='somehow' 

this shows don`t want result (the primary key ) need else shown :(

all table columns can found in mysql's system table columns. column_key field contains 'pri' in case column part of primary key. hence:

select column_name information_schema.columns table_schema = 'mydb'     , table_name = 'somehow'    , column_key <> 'pri'; 

Comments

Popular posts from this blog

php - How to display all orders for a single product showing the most recent first? Woocommerce -

asp.net - How to correctly use QUERY_STRING in ISAPI rewrite? -

angularjs - How restrict admin panel using in backend laravel and admin panel on angular? -