SQL/mySQL question
SQL/mySQL question
- Started
- Last post
- 4 Responses
- heavyt
anyone know the syntax for selecting the primary key from a table?
thanks,
TR1
- unfittoprint0
you should know what's the table's primary key name
then a simple
"SELECT primary_key FROM my_table"
shoul work.
- heavyt0
thanks, but i am actually wondering if there is a way to retreive the key without knowing the name. I am thinking of something like:
select KEY from tablename;
or
select * from tablename where KEY = true;thanks,
TR1
- unfittoprint0
hmmm... I tought so.
"In MySQL, the name of a PRIMARY KEY is PRIMARY(...) You can see index names for a table using SHOW INDEX FROM tbl_name."
- heavyt0
thanks unfit,
worked like a charm. I swear i tried a million different googles, but i couldnt get the result.