Hello,
I have a query in mySQL which I need to use in SQL. Since I dont know a lot SQL i need your help please. This sql lists and sorts pages acording to their parent page like the below example.
Parent Page 1
- Page 1
- Page 2
Parent Page 2
- Page 1
- Page 2
The mySQL script is below
Thanks in advance
I have a query in mySQL which I need to use in SQL. Since I dont know a lot SQL i need your help please. This sql lists and sorts pages acording to their parent page like the below example.
Parent Page 1
- Page 1
- Page 2
Parent Page 2
- Page 1
- Page 2
The mySQL script is below
Code:
SELECT IFNULL(a2.article_weight,ar.article_weight),ar.*,af.articleflag_name FROM tblarticles ar LEFT OUTER JOIN tblarticles a2 ON ar.main_id=a2.article_id LEFT OUTER JOIN tblarticleflag AS af ON af.articleFlag_id = ar.article_flag WHERE ar.category_id = ?cat and ar.article_flag NOT IN (5) GROUP BY ar.article_id ORDER BY IFNULL(a2.article_weight,ar.article_weight), IF(ar.main_id=0,ar.article_id,ar.mainid), IF(ar.main_id=0,0,1),ar.article_weight