Mark Topper
Mark Topper

Reputation: 347

INNER JOIN error

For some reason I have problems with my INNER JOIN, it simply doesn't work.

Here is my code

SELECT
    `hold`.`id` AS `id`,
`hold`.`name` AS `name`
INNER JOIN `instruktorer`
ON `hold`.`ins` = `instruktorer`.`id`
FROM `hold`

The error I get is:

You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INNER JOIN `instruktorer` ON `hold`.`ins` = `instruktorer`.`id` FROM `hold`' at line 4

I make a INNER JOIN almost daily, but now I just cant get it to work.

Hope someone can help me

Upvotes: 0

Views: 152

Answers (3)

Workonphp
Workonphp

Reputation: 1665

The format of writing JOIN is not correct. It should be as following
SELECT 'column_name'..... FROM 'table1' JOIN TYPE 'table2' ON SOME CONDITION

Please check basics here.

Upvotes: 1

juergen d
juergen d

Reputation: 204756

FROM must come before INNER JOIN. Generally all queries have a defined order. For SELECT it goes like this

select
from
join
where
group by
having
order by 
limit

Upvotes: 1

Bogdan Burym
Bogdan Burym

Reputation: 5512

Try this:

SELECT
    `hold`.`id` AS `id`,
`hold`.`name` AS `name`
FROM `hold`
INNER JOIN `instruktorer`
ON `hold`.`ins` = `instruktorer`.`id`

Upvotes: 3

Related Questions