ある日付を含むデータを優先して表示する

プログラム例

$today = "2011-04-26";
$order = " ( dtstart <= '{$tody}' AND '{$today}' <= dtend ) DESC ";

SQLで直接確認する例

|sql|
SELECT
CPID,
dtstart,
dtend,
(
dtstart <= '2011-04-26 00:00:00'
AND '2011-04-26 00:00:00' <= dtend
) AS e
FROM
CPNT
WHERE
dtstart LIKE '2011-0%'
ORDER BY
(
dtstart <= '2011-04-26 00:00:00'
AND '2011-04-26 00:00:00' <= dtend
) DESC
LIMIT 0 , 30
||<