-1
Select Sid,Sname from Salesman
Union all
Select prodId, Category from Product

In the above SQL code,I want to add another column in the resulting table named TYPE which stores S for rows from Salesman Table and P for rows from Product table.

Can anyone help!

jarlh
  • 42,561
  • 8
  • 45
  • 63

1 Answers1

3

Just add it explicitly:

Select Sid, Sname, 'Sales' as source from Salesman
Union all
Select prodId, Category, 'Product'
from Product;
Gordon Linoff
  • 1,242,037
  • 58
  • 646
  • 786