Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL problem

Status
Not open for further replies.

wolf73

Programmer
Feb 12, 2006
93
CA
I have 3 tables , posted_leads, ctc_log, and duplicate_leads. If I I have one record with 'session_id' '22'
and there are 5 records with session_id '22' in table 'duplicate' i get 5 records for session_id '22'. I want to have only one record if there is one record
in table posted_leads for session_id '22'., what am I doing wrong here?




SELECT ctc_log.lead_id, ctc_log.submitted_at, posted_leads.session_id, posted_leads.cluster_id, posted_leads.posted_at,
posted_leads.offer_id, posted_leads.site_id, posted_leads.target, posted_leads.affiliate_id, posted_leads.user_ip,
posted_leads.email, posted_leads.phone, posted_leads.response_code, posted_leads.response, posted_leads.external_id,
posted_leads.success, duplicate_leads.failed, ( ( ( concat(posted_leads.cluster_id,'-',posted_leads.session_id) ) ) )
AS u_session_id FROM posted_leads LEFT JOIN ctc_log ON (posted_leads.session_id = ctc_log.session_id) LEFT JOIN duplicate_leads
ON (posted_leads.session_id = duplicate_leads.session_id) WHERE 1 ORDER BY posted_leads.posted_at DESC


I will appreciate your help...
 
how do you know which one is the first one? i ask this not to be argumentative, but because in a relational database, the rows have no sequence, so "first" is meaningless by itself

r937.com | rudy.ca
 
u are right, actually I was able to take care of it in the code.... thank god this isse is over
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top