문제

I have 2 tables :

albums (idalbum, idauthor, idcompositor, idfeat)
people (id, firstname, last name)

My current Query :

SELECT * FROM albums where idalbum=:id
INNER JOIN people ON albums.idauthor = people.id
INNER JOIN people ON albums.idcompositor = people.id
INNER JOIN people ON albums.idfeat = people.id

What I want to do with my query :

[Album], [Author[First Name, Last Name]], [Compositor[First Name, Last Name]], [Feat[First Name, Last Name]]

My problem:
I have an error : SQLSTATE[42000]: Syntax error or access violation: 1064 You have an error in your SQL syntax;

도움이 되었습니까?

해결책

You need to correct your query where clause should be used after your join statements and also you are not using proper table names, according to structure shown in question you can write your query as

SELECT * FROM albums  a
INNER JOIN people p ON a.idauthor = p.id
INNER JOIN people p1 ON a.idcompositor = p1.id
INNER JOIN people p2 ON a.idfeat = p2.id
where a.idalbum=:id
라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top