Help with Simple SQL

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • malmus
    New Member
    • Jan 2008
    • 18

    Help with Simple SQL

    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
    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
    Thanks in advance
    Last edited by NeoPa; Mar 10 '10, 10:47 AM. Reason: Please use the [CODE] tags provided.
Working...