I have the following:
"SELECT * FROM pages WHERE parent=0 ORDER BY `sort` ASC"
There is a bug somewhere in the system I am working with which means that a page can have a lower sort value than the home page. I am currently looking into this, in the meantime i need the query to enforce that home page comes out first.
Can this query be adapted so it always get’s the page with an id of 1 to appear first, then rest are sorted by the sort column?
If you are going to apply a
LIMITclause to this query, it may be better to split it in two:so that an index on
(parent, sort)can be used.