
Untitled
By: a guest on
Apr 23rd, 2012 | syntax:
None | size: 2.72 KB | hits: 10 | expires: Never
how to put if else condition in 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
)
");
if content_type = 'article'
begin
LIMIT 10
end