is there way perform sql query search multiple dependent clauses? if had table of humans, want humans of (type = student , id = 1)
&& (type = teacher , id = 44)
. can imagine, can expand each bracket multiple statements per bracket , add third, fourth bracket query more types.
the table follows:
humans id type name
so far, forced call same query many times
select * t_humans type = a_type , id = an_id
if understand correctly, generic sql method use more complex boolean conditions:
select h.* t_humans h (type = 'student' , id = 1) or (type = 'teacher' , id = 44);
some databases allow simplify using tuples in
:
select h.* t_humans h (type, id) in (('student', 1), ('teacher', 44));
Comments
Post a Comment