I have the following relation as part of a bigger query:
For a table tbl with columns rowid,a,b,c,d,x ...
Note: ":1" and ":2" are arguments (I'm using Perl DBI).
Now, I would want to use the combination of both SELECTs using EXCEPT over a,b,c but would also be interested in either column rowid or d. Is there a way to achieve this in the same query if any combination a,b,c is not guaranteed to be unique (and therefore cannot be used to identify the row)?
More context: a,b,c are foreign keys into another table and among other things a few LEFT JOINs follow the relation in my "top-level" SELECT. d is also a foreign key into another table but adding either d or rowid to the SELECTs combined by the EXCEPT would miss the point.
Thanks.
Code:
(
SELECT a,b,c
FROM tbl
WHERE x=:1
EXCEPT
SELECT a,b,c
FROM tbl
WHERE x=:2
) r
Note: ":1" and ":2" are arguments (I'm using Perl DBI).
Now, I would want to use the combination of both SELECTs using EXCEPT over a,b,c but would also be interested in either column rowid or d. Is there a way to achieve this in the same query if any combination a,b,c is not guaranteed to be unique (and therefore cannot be used to identify the row)?
More context: a,b,c are foreign keys into another table and among other things a few LEFT JOINs follow the relation in my "top-level" SELECT. d is also a foreign key into another table but adding either d or rowid to the SELECTs combined by the EXCEPT would miss the point.
Thanks.