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
Post a Comment