Celestialchippy
Celestialchippy

Reputation: 271

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.

Upvotes: 0

Views: 56

Answers (1)

Doug Coats
Doug Coats

Reputation: 7107

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

Upvotes: 2

Related Questions