Is there a way to get the name of primary key field from mysql-database? For example:
I have a table like this:
+----+------+ | id | name | +----+---
A better way is to use SHOW KEYS since you don't always have access to information_schema. The following works:
SHOW KEYS
SHOW KEYS FROM table WHERE Key_name = 'PRIMARY'
Column_name will contain the name of the primary key.