per far una roba simile dovresti accedere in lettura al DB information_schema, che contiene i dettagli delle diverse tabelle:
fai un bel: SELECT * FROM information_schema.`COLUMNS` WHERE information_schema.`COLUMNS`.COLUMN_KEY LIKE 'PRI' ed ottieni tutte i campi di tutte le tabelle con PRIMARY KEY.
Se aggiungi AND information_schema.`COLUMNS`.TABLE_NAME LIKE 'TuaTabella' AND information_schema.`COLUMNS`.TABLE_SCHEMA LIKE 'TuoDatabase'
Ottieni il campo PK della tabella che ti serve.
N.B. Questo funzione per MySQL 5.1 (e credo anche per la 5.0), ma non so in quale versione hanno inserito questi nomi, può darsi che in versioni precedenti usassero un DB e/o una tabella e/o un campo diversi