You can use EXISTS to check if a column value exists in a different table.
SELECT
TABLE1.id,
EXISTS (SELECT 1 FROM TABLE2 WHERE TABLE2.id = TABLE1.id) AS columnName
FROM TABLE1
Example:
CREATE TABLE TABLE1 (
id INTEGER PRIMARY KEY,
some_column TEXT NOT NULL
);
CREATE TABLE TABLE2 (
id INTEGER PRIMARY KEY,
some_column TEXT NOT NULL
);
INSERT INTO TABLE1 VALUES
(111, 'lorem ipsum'),
(222, 'and'),
(333, 'some'),
(444, 'random'),
(123, 'strings');
INSERT INTO TABLE2 VALUES
(111, 'lorem ipsum'),
(444, 'random'),
(123, 'strings');
SELECT
TABLE1.id,
EXISTS (SELECT 1 FROM TABLE2 WHERE TABLE2.id = TABLE1.id) AS columnName
FROM TABLE1
Output:
id |
someColumn |
111 |
1 |
123 |
1 |
222 |
0 |
333 |
0 |
444 |
1 |