mysql left join order by null values to the end -
mysql
select * media left join media_priority on (media_priority.media_id = media.id , media_priority.media_tag = '".$tag."') = 'something' order media_priority.media_order;
this works fine except media_priority.media_order comes null , mysql puts null values @ top.
so trying figure out how null tempcol statement left join can order first.....i can't seem syntax right.
where put null statement in query above?
i thinking like:
left join media_priority on (media_priority.media_id = media.id , media_priority.media_tag = '".$tag."') media_priority.media_order null isnull
but doesn't work.
order case when media_priority.media_order null 1 else 0 end, media_priority.media_order;
or use magic number if have upper limit media_order
never feasibly reach.
order coalesce( media_priority.media_order,99999999);
the first approach safer!
Comments
Post a Comment