- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
SELECT ct.com_id, cdt.com_name, ct.tax_id, pt.tax_name, tt.date FROM com_table AS ct LEFT OUTER
JOIN com_des_table AS cdt ON cdt.id = ct.com_id LEFT OUTER JOIN payments_table AS pt ON pt.id =
ct.tax_id LEFT OUTER JOIN tax_table AS tt ON tt.tax_id = ct.tax_id WHERE ct.tax_id LIKE '001%' and
ct.com_id = '1' UNION SELECT ct.com_id, cdt.com_name, ct.tax_id, rt.tax_name, tt.date FROM com_table
AS ct LEFT OUTER JOIN com_des_table AS cdt ON cdt.id = ct.com_id LEFT OUTER JOIN reports_table AS
rt ON rt.id = ct.tax_id LEFT OUTER JOIN tax_table AS tt ON tt.tax_id = ct.tax_id WHERE ct.tax_id LIKE
'002%' and ct.com_id = '1' UNION SELECT ct.com_id, cdt.com_name, ct.tax_id, pt.tax_name, tt.date FROM
com_table AS ct LEFT OUTER JOIN com_des_table AS cdt ON cdt.id = ct.com_id LEFT OUTER JOIN
payments_table AS pt ON pt.id = ct.tax_id LEFT OUTER JOIN tax_table AS tt ON tt.tax_id = ct.tax_id
WHERE ct.tax_id LIKE '001%' and ct.com_id = '0' UNION SELECT ct.com_id, cdt.com_name, ct.tax_id,
rt.tax_name, tt.date FROM com_table AS ct LEFT OUTER JOIN com_des_table AS cdt ON cdt.id = ct.com_id
LEFT OUTER JOIN reports_table AS rt ON rt.id = ct.tax_id LEFT OUTER JOIN tax_table AS tt ON tt.tax_id =
ct.tax_id WHERE ct.tax_id LIKE '002%' and ct.com_id = '0' UNION SELECT ct.com_id, cdt.com_name,
ct.tax_id, pt.tax_name, tt.date FROM com_table AS ct LEFT OUTER JOIN com_des_table AS cdt ON cdt.id =
ct.com_id LEFT OUTER JOIN payments_table AS pt ON pt.id = ct.tax_id LEFT OUTER JOIN tax_table AS tt
ON tt.tax_id = ct.tax_id WHERE ct.tax_id LIKE '001%' and ct.com_id = '2' UNION SELECT ct.com_id,
cdt.com_name, ct.tax_id, rt.tax_name, tt.date FROM com_table AS ct LEFT OUTER JOIN com_des_table AS
cdt ON cdt.id = ct.com_id LEFT OUTER JOIN reports_table AS rt ON rt.id = ct.tax_id LEFT OUTER JOIN
tax_table AS tt ON tt.tax_id = ct.tax_id WHERE ct.tax_id LIKE '002%' and ct.com_id = '2' UNION SELECT
ct.com_id, cdt.com_name, ct.tax_id, pt.tax_name, tt.date FROM com_table AS ct LEFT OUTER JOIN
com_des_table AS cdt ON cdt.id = ct.com_id LEFT OUTER JOIN payments_table AS pt ON pt.id = ct.tax_id
LEFT OUTER JOIN tax_table AS tt ON tt.tax_id = ct.tax_id WHERE ct.tax_id LIKE '001%' and ct.com_id = '3'
UNION SELECT ct.com_id, cdt.com_name, ct.tax_id, rt.tax_name, tt.date FROM com_table AS ct LEFT
OUTER JOIN com_des_table AS cdt ON cdt.id = ct.com_id LEFT OUTER JOIN reports_table AS rt ON rt.id =
ct.tax_id LEFT OUTER JOIN tax_table AS tt ON tt.tax_id = ct.tax_id WHERE ct.tax_id LIKE '002%' and
ct.com_id = '3';
Не помню, что именно. Вырыл в старом логе. К сожалению из-за местных ограничений по длине кода не удалось выложить подобные портянки длинной в 10 тыщ символов.
pee 17.04.2010 21:22 # +9.8
nihau 23.12.2016 20:34 # +1
bormand 23.12.2016 20:35 # +1
inkanus-gray 24.12.2016 10:44 # 0
3_14dar 24.12.2016 18:26 # +1
klem4 17.04.2010 21:38 # 0
guest 17.04.2010 21:51 # +4
C++ 17.04.2010 22:52 # −1.4
guest 17.04.2010 23:53 # −10.6
Washington 18.04.2010 00:10 # 0
Washington 18.04.2010 00:15 # +1
Washington 18.04.2010 00:18 # +1
http://code.ctrl-v.it/code.php?id=416
MoLe-X 18.04.2010 06:48 # +2
guest 19.04.2010 06:13 # 0
guest 19.04.2010 07:35 # 0
mrbig66 19.04.2010 08:39 # +1
И слава Богу.
guest 19.04.2010 13:46 # +4.2
lavrentiev-e 19.09.2010 10:38 # 0
istem 20.09.2010 01:34 # +2
guest 23.12.2016 09:39 # 0
guest 23.12.2016 09:40 # 0
barop 23.12.2016 13:37 # 0
defecate-plusplus 23.12.2016 17:20 # +2
- за like по tax_id руки бы оторвать
- да и за union там, где (мне) очевиден union all (а вот оптимизатору - нихуя не очевидно)
переписанный 1:1 запрос из поста выглядит вот так