SQL join with where beforehand join

Viewed 27

what would be the correct way of doing this so SQL doesn't produce syntax error?

I do have the following (it does work):

SELECT *
FROM table.track
JOIN table.album
ON track.AlbumId = album.AlbumId;

What I look for:

SELECT *
FROM table.track WHERE Name LIKE 'something'
JOIN table.album
ON track.AlbumId = album.AlbumId;

I know it's probably easy, but I can't get the syntax to work...

1 Answers

the where clause must be place after the join clause

    SELECT *
    FROM track
    JOIN album
    ON track.AlbumId = album.AlbumId
    WHERE track.Name LIKE 'something'

and if you need some wildchar

    SELECT *
    FROM track
    JOIN album
    ON track.AlbumId = album.AlbumId
    WHERE track.Name LIKE '%something%'
Related