Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How can I add independant colum?

Author  Topic 

jchoudja
Starting Member

41 Posts

Posted - 2013-03-29 : 12:36:57
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
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2013-03-29 : 13:11:37
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
Master Smack Fu Yak Hacker

1834 Posts

Posted - 2013-03-29 : 13:34:44
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

41 Posts

Posted - 2013-04-02 : 10:49:49
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
   

- Advertisement -