Solved

GoldMine SQL I need a Query

Posted on 2004-08-24
5
246 Views
Last Modified: 2008-03-06
I need a query that will pull related information from three tables.

The Contsupp, Contact1, Contact2

The query is supposed to get me the fields indicated with those primary contact records with email addresses with hose that have comments indicated.

Here is my query but I do not think I am getting it right as it is pulling too much data, do I need to make a join?

select       Contact2.Comments,
      Contact1.Company,
      Contact1.Contact,
      Contact1.Title,
      Contact1.Address1,
      Contact1.Address2,
      Contact1.City,
      Contact1.State,
      Contact1.Zip,
      Contact1.Phone1,
      Contact1.Key2 ,
      Contact1.Key3,
      Contsupp.contsupref,
      CS2.Contsupref+CS2.address1 as email from
      Contact2, Contact1, Contsupp, contsupp as CS2 where
(      (contact2.accountno = contact1.accountno) and (contact1.accountno = contsupp.accountno) and
      Comments = 'mailing listA' and
      CONTSUPP.RECTYPE = 'P' AND
      CONTSUPP.CONTACT = 'E-mail Address'AND
        CONTSUPP.ZIP LIKE '01%')

0
Comment
Question by:ratzephyr
  • 2
5 Comments
 
LVL 17

Expert Comment

by:BillAn1
Comment Utility
you don't have a join to countsub as CS2 - you will need to specify how you want this second copy linked to the other data
0
 

Author Comment

by:ratzephyr
Comment Utility
Sorry, didn't work, still pulling multiple results.  I think I may need a join.
0
 
LVL 17

Accepted Solution

by:
BillAn1 earned 125 total points
Comment Utility
That's what I just said - you need a join between countsub as CS2 and the other tables...
Now, you may not be joining the other tables correctly either, I don't know what the Primary Keys / Foreign Keys etc are on your tables.
0

Featured Post

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Introduction In my previous article (http://www.experts-exchange.com/Microsoft/Development/MS-SQL-Server/SSIS/A_9150-Loading-XML-Using-SSIS.html) I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
This article explains how to reset the password of the sa account on a Microsoft SQL Server.  The steps in this article work in SQL 2005, 2008, 2008 R2, 2012, 2014 and 2016.
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now