MySQL Join Query

后端 未结 3 700
暖寄归人
暖寄归人 2020-12-22 06:19

I am having trouble with a MySQL join query - unfortunately I am not too good with joins.

Table page_section:
-------------------
id
page_id
name
display_ord         


        
相关标签:
3条回答
  • 2020-12-22 07:08

    Try this:

    Select page_section_id.* from page_section_id natural join page_section 
    WHERE page_section_id IN (1,2,3,4,5) order by page_section_id.display_order 
    
    0 讨论(0)
  • 2020-12-22 07:11
    select pss.*
    from page_section_sub pss
    inner join page_section ps on pss.page_section_id = ps.id
    where pss.page_section_id in (1, 2, 3, 4, 5)
    order by ps.display_order
    
    0 讨论(0)
  • 2020-12-22 07:14

    Try this way:

    SELECT * FROM page_section
    LEFT JOIN page_section_sub ON page_section.page_id = page_section_sub.page_id
    WHERE page_section_id IN (1,2,3,4,5) 
    ORDER BY display_order;
    
    0 讨论(0)
提交回复
热议问题