mac007 Posted April 30, 2009 Share Posted April 30, 2009 Hi, all: I have this statement: "SELECT DISTINCT offer_email, email_subject, email_body FROM email_blast, customer_emails_copy WHERE id = $itemid" I have two tables, and the "offer-email" belongs to the customer_emails_copy one. I also want to select the other fields from second table normally (not DISTINCT), is this the right way? I dont seem to be getting what I expect... Thanks for your help! Link to comment https://forums.phpfreaks.com/topic/156215-select-statement-with-distinct-but-with-fields-from-two-tables/ Share on other sites More sharing options...
Ken2k7 Posted April 30, 2009 Share Posted April 30, 2009 Wrong forum to post this in. Your SQL says offer_email. Is it offer_email or offer-email? As far as I know, DISTINCT works across all columns you select. Which column do you want distinct? Be careful if both table has an ID field. You may want to specify which id gets used in your WHERE clause. Same for those columns you select. I would write this: SELECT offer_email, email_subject, email_body FROM email_blast, customer_emails_copy WHERE id = '$itemid' GROUP BY offer_email Link to comment https://forums.phpfreaks.com/topic/156215-select-statement-with-distinct-but-with-fields-from-two-tables/#findComment-822424 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.