From: Peter Brawley Date: February 12 2007 5:12pm Subject: Re: Select Primary Key List-Archive: http://lists.mysql.com/mysql/204944 Message-Id: <45D09FF0.60609@earthlink.net> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Rich, >How can I select primary key from a table? To retrieve PKs for db.tbl in MySQL 5 ... SELECT k.column_name FROM information_schema.table_constraints t JOIN information_schema.key_column_usage k USING(constraint_name,table_schema,table_name) WHERE t.constraint_type='PRIMARY KEY' AND t.table_schema='db' AND t.table_name='tbl'; Pre-5, parse the result of DESC tbl or SHOW KEYS FROM tbl. PB Rich wrote: > Hi folks. How can I select primary key from a table? I can't find > any syntax out of show fields from tablename, and the 'key' field = > "PRI". Just seems to be a bit much. > > Any takers? > > Cheers > > > Rich in Toronto (cold) > > > > --MySQL General Mailing List > For list archives: http://lists.mysql.com/mysql > To unsubscribe: > http://lists.mysql.com/mysql?unsub=peter.brawley@stripped > > > > --No virus found in this incoming message. > Checked by AVG Free Edition. > Version: 7.1.411 / Virus Database: 268.17.37/682 - Release Date: > 2/12/2007 > > -- No virus found in this outgoing message. Checked by AVG Free Edition. Version: 7.1.411 / Virus Database: 268.17.37/682 - Release Date: 2/12/2007