Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Retrieving columns from related tables Expand / Collapse
Author
Message
Posted Thursday, October 21, 2010 10:28 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, October 26, 2010 3:52 AM
Points: 3, Visits: 9
Hi everyone,
I have a design like the one attached to this post and i want to be able to query the tiers table and return the name field from the 3 tables related to tiers.

I want the the firstname and lastname in Person concatenated to name

In the end i want something like this

TierId NAME
1 Gabriel G
2 Microsoft
3 My group

Thank you


  Post Attachments 
schema.png (8 views, 110.94 KB)
Post #1008651
Posted Thursday, October 21, 2010 11:17 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Wednesday, September 10, 2014 2:56 PM
Points: 160, Visits: 502
Would something like this work for you

Select Concat ( firstName,LastName) OR Select firstName|| ' ' || LastName
Into A.Name
FRom Table A A Inner JOIN TableB B
where A.ID = B.ID
Post #1008677
Posted Friday, October 22, 2010 9:35 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, October 26, 2010 3:52 AM
Points: 3, Visits: 9
Thanks SQLTestUser. I'd try it out and let you know
Post #1009306
Posted Saturday, October 23, 2010 4:12 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, October 26, 2010 3:52 AM
Points: 3, Visits: 9
I get the code you have pasted but that really isn't what i want.

The three tables related to tiers have somethings in common, the name field except for Persons that has firstname and lastname. I want to pull data from all the three tables along with the named field
Post #1009585
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse