MySQL query issue with left joining a table with the results of two other tables -


i trying select data 1 table results of data coming out joining 2 different tables, getting error , can not figure out:

select concat(firstname,lastname) staffname `cms_users` right join (select distinct concat(a.firstname," ",a.lastname) clientname, b.doa `cms_clients` inner join `cms_question_report` b on a.id = b.cid b.doa < '2015-04-15 23:00:00' , b.doa > '2015-04-09 00:00:00') incidents 

the error getting is:

you have error in sql syntax; check manual corresponds mysql server version right syntax use near 'limit 0, 30' @ line 9

but don't have limit 0,30 in query.

your query incomplete. missing joining columns right join. see below, must replace primary_key primary key cms_users table. make sure i.id correct joining column 2 tables.

select concat(firstname,lastname) staffname `cms_users` right join (select distinct concat(a.firstname," ",a.lastname) clientname, b.doa `cms_clients` inner join `cms_question_report` b on a.id = b.cid b.doa < '2015-04-15 23:00:00' , b.doa > '2015-04-09 00:00:00')   on i.id = cms_users.primary_key 

i hope helps!