テーブルに order by 設定があり、このオプションでsettings
変更order by
したいのですが、以下の SQL コマンドでこのオプションを使用sortable
します。正しいSQLコマンドを教えてくださいsettings
ORDER BY DATE
sortable
ORDER BY ID
マイSQL:
SELECT
SQL_CALC_FOUND_ROWS i.* ,
c.title AS category_name,
u.name,
u.family,
s.title AS status_title,
i.thumb_image,
CONCAT( u.name, ' ', u.family ) AS author
FROM contents i
JOIN categories c ON c.id = i.category
JOIN users u ON u.id = i.posted_by
JOIN status_topics s ON s.id = i.t_status
WHERE
i.portal = 0
AND (CASE WHEN post_type = 4
THEN date(NOW()) BETWEEN i.from_dateTime AND i.to_dateTime
ELSE post_type = 1
END)
(select sortable from settings)
(case when sortable = 1 then
ORDER BY topic_date
case when sortable = 2 then
ORDER BY id
case when sortable = 3 then
ORDER BY public
end)
LIMIT 10