learner123
learner123

Reputation: 961

help with alias sql

i am trying to learn about alias in sql for my course however i do not fully understand the command. As part of the work i must do this:

  1. Understanding Complex SQL Queries (a) Select all columns / fields from master tracks and sound engineer joining the two based on the sound engineers ID and using an alias for each table.

i have got to here:

SELECT * 
FROM SOUNDENGINEER AS s 
INNER JOIN MASTERTRACK AS m ON m.EDITED_BY,s.SOUND_ENG_ID;

but now i am stuck please help

Upvotes: 1

Views: 180

Answers (4)

learner123
learner123

Reputation: 961

   SELECT * FROM  SOUNDENGINEER  s INNER JOIN  MASTERTRACK m ON   m.EDITED_BY = s.SOUND_ENG_ID;

this seems to work

Upvotes: 1

Jahan Zinedine
Jahan Zinedine

Reputation: 14874

It's correct but ON clause should be like this On m.EDITED_BY=s.SOUND_ENG_ID;

SELECT * FROM SOUNDENGINEER AS s 
 INNER JOIN MASTERTRACK AS m ON m.EDITED_BY = s.SOUND_ENG_ID;

Upvotes: 5

Mutation Person
Mutation Person

Reputation: 30498

Almost right. Try:

SELECT * 
FROM SOUNDENGINEER AS s 
INNER JOIN MASTERTRACK AS m ON m.EDITED_BY = s.SOUND_ENG_ID;

Your use of the comma might suggest you were trying the alternate equi-join syntax, which would be:

SELECT * 
FROM SOUNDENGINEER AS s, MASTERTRACK AS m 
WHERE m.EDITED_BY = s.SOUND_ENG_ID;

I prefer the former though, as you are explicitly stating that you are joining the tables with an INNER JOIN statement.

Upvotes: 1

mingos
mingos

Reputation: 24502

SELECT * FROM SOUNDENGINEER AS s INNER JOIN MASTERTRACK AS m ON m.EDITED_BY = s.SOUND_ENG_ID;

Upvotes: 2

Related Questions