Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

You can use a column name as data in the IN() clause in a subquery in SQLite by surrounding the column name with single quotes and concatenating it with the rest of the subquery as follows:

SELECT column1, column2, ...
FROM table1
WHERE column3 IN (
  SELECT column4
  FROM table2
  WHERE column5 = 'value'
  AND column4 = ''' || table1.column6 || '''
);

In the above query, the column6 of the table1 is used as data in the IN() clause of the subquery. The double quotes inside the single quote are used to escape the single quote in the SQL query.