I\'m, generating a SQL query like this in PHP:
$sql = sprintf(\"UPDATE %s SET %s = %s WHERE %s = %s\", ...);
Since almost every part of thi
It might be not advised but works just fine:
SHOW INDEX FROM WHERE Key_name = 'PRIMARY';
The solid way is to use information_schema:
SELECT k.COLUMN_NAME
FROM information_schema.table_constraints t
LEFT JOIN information_schema.key_column_usage k
USING(constraint_name,table_schema,table_name)
WHERE t.constraint_type='PRIMARY KEY'
AND t.table_schema=DATABASE()
AND t.table_name='owalog';
As presented on the mysql-list. However its a few times slower from the first solution.