How to select specific column types in SQLite3?

Viewed 351
PRAGMA table_info(myTable)

This query selects all the info in a table, for example: if there are 2 columns in a table then this query will select all the column names, column types e.t.c

I just want add one clause i.e I want to get info of specific columns that I define in the query.

Like this:

PRAGMA table_info(myTable) where columnNames = 'a' and columnNames = 'b' // this is wrong query but I just mentioned it to make my question more clear.

How can I do this?

1 Answers

You can pragma_table_info() in a query with a WHERE clause:

SELECT * 
FROM pragma_table_info('myTable') -- note the single quotes
WHERE name IN ('a', 'b') -- equivalent: name = 'a' OR name = 'b'

See the demo.

Related