I'm trying to do this query. I have these three tables projects id name
authors
id
id_user
fk_id project
type = author, editor
in Table I have authors who is the creator and who is the editor I'm trying to make a query in mysql where you can see in one record who is the author and publisher.
I do the consultation with one of the two
SELECT p.id_project,p.name_project,a.fk_id_user,a.type,u.name
FROM projects p,users u, authors a
where p.id_project = a.fk_id_project
and a.type = 'author'
and a.fk_id_user = u.id_user
the result is
id_project, name_proyect, type, user, name_user
1 , bambo, author, 145, andrea
want is to do this
id_project, name_proyect, type, user, name_user, type2, user2, name_user2
1 ,bambo , author,145, andrea, editor, 785, barack
try to do this but not worked
SELECT p.id_project,p.name_project,a.fk_id_user,a.type,u.name,a.fk_id_user as user2, a.tipo as type2
FROM
projects p, users u, authors to
where p.id_project = a.fk_id_project
and a.type = 'author'
and a.fk_id_user = u.id_user
and user2 = u.id_user
and Typo2 = 'editor'
That type of query could use or if I'm doing wrong this.
projects p, users u, authors toa typo? if not you need to changeauthors totoauthors a