how to get values for same column name from two different tables in SQL
How to get values for same column name from two different tables in SQL?
column name is emp_id
loacated in these two 开发者_JAVA百科tables: company,employee
.
If you want data in seperate columns from two tables then try :
SELECT c.emp_id, emp.emp_id
FROM company c
INNER JOIN employee emp on c.company_id = emp.company_id
If you want to merge both columns data then use this :
SELECT emp_id FROM company
UNION
SELECT emp_id FROM employee
Use this to get the results:
company.emp_id, employee.emp_id
You can do what you are asking, something like the example below, but if you provide a sample query, it would help...
select emp.emp_id,company.emp_id
from company
join employee emp on emp.company_id=company_company_id
Just put the name of the table before the name of the colomn with a "." between, like:
SELECT company.emp_id, employe.emp_id
精彩评论