I have a table that looks like this:
CREATE TABLE public.mytable (
p_id varchar(40) NOT NULL,
j_id varchar(48) NOT NULL,
u_id varchar(255) NOT NULL
);
I'm using the following to find rows based on p_id and j_id:
SELECT * FROM mytable WHERE p_id = ? AND j_id = ? LIMIT 10
I want to extend this query so that it also excludes some rows, for example, I have a list like this:
class MyEntity {
public p_id
public j_id;
public u_id;
}
List<MyEntity> rowsToExclude = new ArrayList<>();
rowsToExclude.add(new MyEntity(1, 3, 5));
rowsToExclude.add(new MyEntity(7, 8, 9));
How do I feed the rowsToExclude
into the query, maybe using a NOT IN?
For example, (not real code), something like:
SELECT * FROM mytable WHERE p_id = ? AND j_id = ?
AND NOT IN(rowsToExclude)
LIMIT 10
Related: