ExpressionEngine CMS
Open, Free, Amazing

Thread

This is an archived forum and the content is probably no longer relevant, but is provided here for posterity.

The active forums are here.

Need help with basic query statement.

March 29, 2011 2:44pm

Subscribe [2]
  • #1 / Mar 29, 2011 2:44pm

    Geoff Towle

    330 posts

    I simply can’t wrap my brain around how to pull data from two tables.  I have the below statement which is not working right - it’s not pulling the email data.  I’m guessing it has to do with how I’m trying to write the WHERE statement.  I have read SQL documentation about Inner Join, etc., but it’s not clicking.

    Could someone lend a helping hand and show me where I’m going wrong?  Thanks.

    {exp:csvee query="SELECT email, m_field_id_5 email FROM exp_members, exp_member_data WHERE exp_members.member_id = exp_member_data.member_id"}
  • #2 / Mar 29, 2011 2:49pm

    Geoff Towle

    330 posts

    As it normally goes, as soon as I posted this topic I noticed an extraneous “email” in the statement.  Once I removed that, it worked.  Thanks again, EE Gods.

    That said, I’m always willing to learn so if anyone reading this has a recommendation for my query I’m all ears.

  • #3 / Mar 29, 2011 2:54pm

    Mark Bowen

    12637 posts

    See if this works instead :

    {exp:csvee query="
    
    SELECT m.email, d.m_field_id_1
    FROM exp_members m
    LEFT JOIN exp_member_data d
    ON m.member_id = d.member_id
    
    "}

    Best wishes,

    Mark

  • #4 / Mar 29, 2011 3:43pm

    Geoff Towle

    330 posts

    Mark,

    Thanks for that.  Got the same, positive, results.  I’ll dig deeper and try to get a better understanding of your method.

    Cheers!

    Geoff

.(JavaScript must be enabled to view this email address)

ExpressionEngine News!

#eecms, #events, #releases