- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
SELECT * FROM obj WHERE telephon LIKE '***' AND off = 0;
SELECT obj.* FROM
obj
INNER JOIN obj2ls ON obj.ObjID = obj2ls.ObjKod AND obj2ls.Bdate <= CURDATE() AND obj2ls.Edate >= CURDATE() AND obj2ls.off = 0
INNER JOIN ls ON obj2ls.LsKod = ls.lsid AND ls.off = 0
INNER JOIN ls2contr ON ls.lsid = ls2contr.lskod AND ls2contr.bdate <= CURDATE() AND ls2contr.edate >= CURDATE() AND ls2contr.off = 0
INNER JOIN contr ON ls2contr.contrkod = contr.contrid AND contr.off = 0
WHERE obj.telephon LIKE '***' AND obj.off = 0 AND contr.contr_type = 2;
О плохом проектировании базы данных.
Был простой запрос, к нему добавили проверку 1го(!) доп. условия.
Еще умиляют JOINы в духе *Kod = *Id.
guest 19.01.2010 16:05 # +3.2