這裏是我的查詢如何把如果LIMIT MySQL的其他條件
$where_or = "
AND
content_status = 'Active'
AND
content_post_status = 'published'
AND
deleted = 0
AND
content_type = '$type'
ORDER BY content_created_at DESC ";
$select = "content_id, content_title, content_short_description, content_url, content_created_at";
$query = $this->db->query("
(
SELECT $select
FROM tbl_content
WHERE
content_category_id = 54
$where_or
LIMIT 3
)
UNION ALL
(
SELECT $select
FROM tbl_content
WHERE
content_category_id = 55
$where_or
LIMIT 2
)
UNION ALL
(
SELECT $select
FROM tbl_content
WHERE
content_category_id = 56
$where_or
LIMIT 2
)
UNION ALL
(
SELECT $select
FROM tbl_content
WHERE
content_category_id = 57
$where_or
LIMIT 1
)
UNION ALL
(
SELECT $select
FROM tbl_content
WHERE
content_category_id = 58
$where_or
LIMIT 1
)
UNION ALL
(
SELECT $select
FROM tbl_content
WHERE
content_category_id = 60
$where_or
LIMIT 1
)
UNION ALL
(
SELECT $select
FROM tbl_content
WHERE
content_category_id = 61
$where_or
LIMIT 1
)
UNION ALL
(
SELECT $select
FROM tbl_content
WHERE
content_category_id = 118
$where_or
if content_type = 'article'
begin
LIMIT 10
end
)
");
可以在最後UNION看到我想提出的限制。如果條件..但它給我的錯誤...我怎麼能這樣做...請幫助..
那......沒有任何意義。 – Konerak 2012-03-06 06:13:53
我解決了它與php ..感謝 – saba 2012-03-06 06:20:52