1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

How to select specific fields from pivot table that matches exact values

Discussion in 'MySQL' started by Kuna, Dec 6, 2021.

  1. #1
    I have 3 tables
    - conversations - I save basic information about the conversation
    - users - Infor about user
    - conversation_users - table that saves information about which user belongs to which conversation

    In my case user "1" wants to get a conversation between him and users: 3, 4, 5. So I'm trying to fetch conversation_id = 12. First I need to find all conversations user "1" belongs to, that is conversation_id "1" and "12".

    Next I'm executing `SELECT * FROM conversations_users WHERE conversation_id in (1,12)`. How do I pick rows marked in red rectangle?

    [​IMG]
     
    Kuna, Dec 6, 2021 IP