简体   繁体   中英

Join two different sql tables with columns that have the same data

I have two different sql statements I'm executing and one works and the other one semi works if I remove the ambiguous column. Is there a way to specify which columns I want to grab information from on both tables?

select * from currentprojects
     Join Group on Group.projectcode= currentprojects.projectcode

This is the first statement and it works but when the table is displayed the whole page breaks.

SELECT 
   name,
   projectid,
   projectcode,
   completiondate,
   meeting,
   status
FROM currentprojects
Join Group on Group.status= currentprojects.projectcode

The second statement works if I remove projectcode from the query, but I want to have both datasets showing different things.

try this. Aliasing helps once your queries start getting pretty dense

 SELECT cp.Cloumn, g.Column 
 FROM currentprojects cp
 INNER JOIN Group g ON g.projectcode= cp.projectcode

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM