SQLite – How to get the primary key column name for a given table?

All I know is the name of the table and the id value of the query I want to execute, but I don’t know what id is called in the table.
You can use the answer to a quite similar question to find the column name of the primary key column.

sqlite> pragma table_info(...)

If needed, it should also work programmatically.

All I know is the table name and what I want to execute The id value of the query, but I don’t know what the id is called in the table.

You can use the answer to a quite similar question to find the column name of the primary key column.

sqlite> pragma table_info(...)

If needed, it should also work programmatically.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 880 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.