Subject | Is particular combination of childs already in table |
---|---|
Author | ainpoissee |
Post date | 2006-07-03T15:48:23Z |
Hi!
I have tables like
CREATE TABLE TAB_AnalGrupp (
UID DOM_PK PRIMARY KEY,
Nimi DOM_NIMI UNIQUE
);
CREATE TABLE TAB_AnalGrItem (
UID DOM_PK PRIMARY KEY,
Grupp DOM_FK CONSTRAINT FK_AGI_Grupp REFERENCES
TAB_AnalGrupp(UID)ON UPDATE CASCADE ON DELETE CASCADE,
Kood DOM_FK CONSTRAINT FK_AGI_Kood REFERENCES TAB_Analkood(UID)
ON UPDATE CASCADE ON DELETE CASCADE,
CONSTRAINT CU_AnalGrItem UNIQUE(Grupp,Kood)
);
and I want to query is given set of "Kood"s already in TAB_AnalGrItem.
I.e. say TAB_AnalGrItem contains
Grupp Kood
2 10
2 12
3 10
3 11
3 15
and I want to know is combination Kood(10, 12) alredy in DB. Answer is
yes - Grupp 2. I guess I could join TAB_AnalGrItem to itself but I'm
wondering is there some simpler, more elegant way to do this?
TIA
ain
I have tables like
CREATE TABLE TAB_AnalGrupp (
UID DOM_PK PRIMARY KEY,
Nimi DOM_NIMI UNIQUE
);
CREATE TABLE TAB_AnalGrItem (
UID DOM_PK PRIMARY KEY,
Grupp DOM_FK CONSTRAINT FK_AGI_Grupp REFERENCES
TAB_AnalGrupp(UID)ON UPDATE CASCADE ON DELETE CASCADE,
Kood DOM_FK CONSTRAINT FK_AGI_Kood REFERENCES TAB_Analkood(UID)
ON UPDATE CASCADE ON DELETE CASCADE,
CONSTRAINT CU_AnalGrItem UNIQUE(Grupp,Kood)
);
and I want to query is given set of "Kood"s already in TAB_AnalGrItem.
I.e. say TAB_AnalGrItem contains
Grupp Kood
2 10
2 12
3 10
3 11
3 15
and I want to know is combination Kood(10, 12) alredy in DB. Answer is
yes - Grupp 2. I guess I could join TAB_AnalGrItem to itself but I'm
wondering is there some simpler, more elegant way to do this?
TIA
ain