Задавайте вопросы, мы ответим
Вы не зашли.
SELECT
c.id card,
b.name b_name,
b.document_url b_url,
ug.id_package,
o.id,
o.title,
o.description,
o.telephone,
o.publish_site,
o.date_create,
o.city adress,
s.domain site
FROM links l
JOIN `usage` u ON l.`id_usage` = u.`id`
JOIN `organizations` o ON l.`id_organization` = o.id
JOIN `cards` c ON o.id = c.`id_organization`
JOIN `usage_groups` ug ON o.id = ug.`id_organization`
JOIN `businesses` b ON b.id = l.id_business
JOIN `sites` s ON o.id = s.id_organization
LEFT JOIN `businesses` b2 ON b2.`id` = b.`id_parent`
LEFT JOIN `businesses` b3 ON b3.`id` = b2.`id_parent`
LEFT JOIN `businesses` b4 ON b4.`id` = b3.`id_parent`
WHERE o.publish = 'Y'
AND 189 IN (
l.`id_business`,
b.`id_parent`,
b2.`id_parent`,
b3.`id_parent`,
b4.`id_parent`
)
GROUP BY ug.`id_organization`
ORDER BY ug.id_package DESC, o.date_create
UNION ALL
SELECT
NULL card,
b.`name` b_name,
b.`document_url` b_url,
NULL id_package,
'' id,
ow.OrgName title,
'' description,
ow.Telephone telephone,
'' publish_site,
NULL date_create,
ow.Adress adress,
NULL site
FROM orgs_wait ow
LEFT JOIN orgs_wait_cards owc ON ow.DocID = owc.DocID
JOIN `businesses` b ON b.id = ow.`id_business`
LEFT JOIN `businesses` b2 ON b2.`id` = b.`id_parent`
LEFT JOIN `businesses` b3 ON b3.`id` = b2.`id_parent`
LEFT JOIN `businesses` b4 ON b4.`id` = b3.`id_parent`
LEFT JOIN regions r1 ON r1.id = ow.id_region
LEFT JOIN regions r2 ON r2.id = r1.id_parent
WHERE
(
owc.id_card IS NULL
OR
ow.`Status` IN (12, 13)
)
AND 189 IN (
ow.`id_business`,
b.`id_parent`,
b2.`id_parent`,
b3.`id_parent`,
b4.`id_parent`
)
AND 123 IN (
ow.id_region,
r1.id_parent,
r2.id_parent
)
LIMIT 0, 10
ERROR 1221 (HY000): Incorrect usage of UNION and ORDER BY
Хочется чтобы в первом запросе выполнялась сортировка а второй просто приклеивался при нехватке 10 элементов.
Неактивен
Брр... я пугаюсь Ваших запросов
(SELECT ... ORDER BY .. ) UNION (SELECT ...) LIMIT
Скобочки поставьте
Неактивен