Joseph L. Casale wrote:
>  SELECT x.id, x.col
>   FROM table_a x
> EXCEPT
> SELECT y.id, y.col
>   FROM table_b y
>     JOIN table_a .....

This query is not complete, but as far as I can tell, it is intended to
return table_a rows that do not have a matching table_b row.  Is this
correct?

> now I need to return row ids for each record on the left and these
> certainly don't match the row ids from the right hand side.

There are two ways to rewrite this query, with a correlated subquery:

 SELECT *
 FROM table_a AS x
 WHERE NOT EXISTS (SELECT 1
                   FROM table_b AS y
                   WHERE x.id  = y.id
                     AND x.col = y.col)

or with an outer join:

 SELECT x.*
 FROM      table_a AS x
 LEFT JOIN table_b AS y USING (id, col)
 WHERE y.id IS NULL


Regards,
Clemens
_______________________________________________
sqlite-users mailing list
[email protected]
http://sqlite.org:8080/cgi-bin/mailman/listinfo/sqlite-users

Reply via email to