Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Create dynamic column

Status
Not open for further replies.

loveccb

Programmer
Joined
Dec 9, 2005
Messages
4
Location
US
Hi all,

I have a statement:

SELECT aff_code, aff_name, pw FROM affiliates WHERE aff_code = 'snow'
UNION ALL

SELECT aff_code, aff_name, pw FROM associates WHERE aff_code = 'snow'

But I want to know based on my query which table each row came from(associates or affiliates). Can I create a dynamic column or something? Thanks!
 
SELECT 'affiliates' tblOrig, aff_code, aff_name, pw FROM affiliates WHERE aff_code = 'snow'
UNION SELECT 'associates', aff_code, aff_name, pw FROM associates WHERE aff_code = 'snow'


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Good lord, thank you PH. I was pulling my hair out on this one.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top