Может кто-нибудь сказать, пожалуйста, какой из этих двух запросов лучше другого и почему?Стоит ли использовать вместо этого соединение?
select * from grandChildTable gct
where exists(
select * from childTable ct
where some condition
and gct.parentId = ct.Id
and exists(
select * from Table t
where some other condition
and ct.parentId = t.Id))
select * from grandChildTable gct
where exists(
select * from childTable ct
where some condition
and gct.parentId = ct.Id)
and exists(
select * from Table t
where some other condition
and gct.grandParentId = t.Id)
ПРИМЕЧАНИЯ: GrandChildTable
имеет идентификаторы для ChildTable
и Table
, поскольку идентификаторы составные.
Таблицы нене имеет ссылок на любые другие.
Отношения между таблицами:
GrandChild to Child
n:1
Child to Table
n:1