Help need with query

  • SQL query:

    SELECT m.memb_id, m.memb_email, m.memb_created_date, m.memb_status, g.grp_name, CONCAT( m.memb_lastname, ', ', m.memb_firstname ) AS memb_name

    FROM git_members AS m

    LEFT JOIN (

    git_members_group AS g

    ) ON ( g.grp_id = m.memb_grp_id )

    LEFT JOIN (

    git_members_profile AS d

    ) ON ( d.memb_id = m.memb_id )

    WHERE g.grp_id != '1'

    AND (

    (

    m.memb_email LIKE 'r%'

    )

    OR (

    m.memb_grp_id =6

    )

    AND (

    m.memb_status = '1'

    )

    )

    AND g.grp_type_id =1

    ORDER BY m.memb_id DESC

    Im suppose to get the details of the user whose

    m.memb_email starts with r

    m.memb_grp_id =6 ie admin role

    m.memb _status = '1' ie active

    But the result gives inactive users also

    Ie m.memb_status = '0' .

    Can anyone please tell me if thr is something wrong in the query.

    Tanx 😀

  • Hi Eswin

    Your query works with the braces around the joined table names? I get a syntax error on my system. I removed them and now it works (parse).

    I think you have to move your status-criterion out of the OR braces:

    SELECT

    m.memb_id,

    m.memb_email,

    m.memb_created_date,

    m.memb_status,

    g.grp_name

    --,

    --CONCAT( m.memb_lastname, ', ', m.memb_firstname ) AS memb_name

    FROM git_members AS m

    LEFT JOIN git_members_group AS g ON ( g.grp_id = m.memb_grp_id )

    LEFT JOIN git_members_profile AS d ON ( d.memb_id = m.memb_id )

    WHERE g.grp_id != '1'

    AND (

    (m.memb_email LIKE 'r%')

    OR (m.memb_grp_id =6)

    )

    AND (m.memb_status = '1')

    AND g.grp_type_id =1

    ORDER BY m.memb_id DESC

    Greets

    Flo

  • Yes that worked. Thanks a lot Florian

    Tanx 😀

  • Glad that I could help!

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply