[dba-SQLServer] dba-SQLServer Digest, Vol 71, Issue 8

Robert L. Stewart robert at webedb.com
Mon Feb 2 13:03:33 CST 2009


Jean-Paul,

The point is how to join the tables together.
They have to have a common field. What is it?

Once you get that, they you can work about what
data to return.


At 12:00 PM 1/31/2009, you wrote:
>Date: Sat, 31 Jan 2009 11:54:58 -0500
>From: jean-paul <jnatola at hotmail.com>
>Subject: Re: [dba-SQLServer] Newbie needs help with select statement
>To: <dba-sqlserver at databaseadvisors.com>
>Message-ID: <BAY140-W230FA6B07C1B8423C0FF73BCC70 at phx.gbl>
>Content-Type: text/plain; charset="iso-8859-1"
>
>
>the contacts table has 24 fields id first_name last_name  etc.., I 
>want every single record and field from that table.the 
>contacts_org_types table has three fields  id organization_type and 
>internal, I want only the organization_type field from that table, 
>so , I *believe* that i should see 25 fields in my result  24 from 
>table 1 and 1 from table 2- thanks          Jean-Paul Natola > From: 
>markamatte at hotmail.com> To: dba-sqlserver at databaseadvisors.com> 
>Date: Sat, 31 Jan 2009 12:49:06 +0000> Subject: Re: [dba-SQLServer] 
>Newbie needs help with select statement> > > I hate to make 
>assumptions...but the subject says 'newbie'...and Francisco 
>suggested the fields to join on...not Jean Paul.> > Jean Paul, what 
>fields from each table are you trying to join on(the actual field 
>names)? > > If the example below was used 'as is' and there is an 
>'ID' field in each table but its not the relationship between these 
>two tables...won't give the results.> > As long as I am 'assuming'...I think!
>   the scenario might be a translation table...and the first attemp 
> produced a cartesian join(no joins) and listed each contact having 
> every kind of cust_org_types...so the confusion might be what 
> fields to join on.> > Francisco's Example modified:> > SELECT * 
> FROM contacts AS ctcs> INNER JOIN contacts_organization_types AS 
> cot ON ctcs.cust_org_types = cot.id> > I'm guessing there is a 
> cust_org_types field in the contacts table...and there is a value 
> that needs to be translated?> > If I am off target...please let me 
> know.> > Thanks,> >>
>_________________________________________________________________





More information about the dba-SQLServer mailing list