SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How can I add independant colum?
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

jchoudja
Starting Member

USA
41 Posts

Posted - 03/29/2013 :  12:36:57  Show Profile  Reply with Quote
Hi,
I willike to add independant column to my table (Not included in the table)
Exemple
Table Artists (ArtistsID,ArtistName, ArtistsDOB)
Table concerts (ArtistsID, ConcertDate, ConcertLocation)
I want to produice
SELECT a.ArtistsID,a.ArtistName,c.ConcertDate,c.ConcertLocation
From Artists a INNER JOIN Concerts c ON a.ArtistsID=c.ArtistsID

What should I add to get Rep=Manager (Rep is the column mane, Manager is the column Value)

ArtistsID_|_ArtistName_|_ConcertDate_|_ConcertLocation_|_Rep
---------------------------------------------------------------------
1_________|_John_______|_03/10/2013__|_New York________|_Manager
2_________|_Sony_______|_04/11/2013__|_Chicago_________|_Manager
3_________|_Maria______|_05/12/2013__|_Houston_________|_Manager

Thank you for your help



jc

Lamprey
Flowing Fount of Yak Knowledge

4363 Posts

Posted - 03/29/2013 :  13:11:37  Show Profile  Reply with Quote
I'm not 100% sure I'm following your requirements, but maybe this?
SELECT a.ArtistsID,a.ArtistName,c.ConcertDate,c.ConcertLocation, 'Manager' AS Rep
From Artists a INNER JOIN Concerts c ON a.ArtistsID=c.ArtistsID
Go to Top of Page

Bustaz Kool
Flowing Fount of Yak Knowledge

USA
1600 Posts

Posted - 03/29/2013 :  13:34:44  Show Profile  Reply with Quote
I'm even less sure that I'm following your requirements BUT if you want the literal string "Manager" to appear in your output, follow Lamprey's advice (usually a good idea anyway). If you want the name of the manager to appear and a Manager typically is attached to a single artist, then add a column to the Artist table using the ALTER TABLE command. If one manager has multiple artists then create a Manager table and define a foreign key relationship by adding a linking column in the Artist table using the ALTER TABLE and create the FOREIGN KEY constraint. If, on the other hand, I have completely missed the point of your requirements, ignore this post in its entirety.

=================================================
There are two kinds of light -- the glow that illuminates, and the glare that obscures. -James Thurber
Go to Top of Page

jchoudja
Starting Member

USA
41 Posts

Posted - 04/02/2013 :  10:49:49  Show Profile  Reply with Quote
Thank you. It worked with 'Manager' AS Rep

I have no control on tables. I use UNION ALL to link 2 queries manager is the same for each querie.


jc
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.06 seconds. Powered By: Snitz Forums 2000