i write sql
SELECT
count(*) as count,g.name
FROM
test_scale g
INNER JOIN
test_user_scale_result a
INNER JOIN
en_org_user_department b
INNER JOIN
en_org_department d
INNER JOIN
test_scale_type e ON a.user_id = b.user_id
AND g.id = a.scale_id
AND b.department_id = d.id
AND d.position LIKE CONCAT((SELECT
position
FROM
en_org_department
WHERE
id = 8),
'%')
AND e.id = g.scale_type_id
and b.status = 1
and g.scale_type_id IN (1 , 9)
and a.create_time BETWEEN '2015-01-07 18:09:45' and '2015-11-09 18:09:45'
group by a.scale_id;
i run correctly. but when i change inner to left,like
SELECT
count(*) as count,g.name
FROM
test_scale g
left JOIN
test_user_scale_result a
left JOIN
en_org_user_department b
left JOIN
en_org_department d
left JOIN
test_scale_type e ON a.user_id = b.user_id
AND g.id = a.scale_id
AND b.department_id = d.id
AND d.position LIKE CONCAT((SELECT
position
FROM
en_org_department
WHERE
id = 8),
'%')
AND e.id = g.scale_type_id
and b.status = 1
and g.scale_type_id IN (1 , 9)
and a.create_time BETWEEN '2015-01-07 18:09:45' and '2015-11-09 18:09:45'
group by a.scale_id;
it error 20:37:15 SELECT * FROM test_user_scale_result a
left JOIN en_org_user_department b left JOIN
en_org_department d left JOIN test_scale_type e left JOIN test_scale g ON a.user_id = b.user_id AND g.id = a.scale_id AND b.department_id = d.id AND d.position LIKE CONCAT((SELECT position FROM en_org_department WHERE id = 8),
'%') AND e.id = g.scale_type_id and b.status = 1
and g.scale_type_id IN (1 , 9) and a.create_time BETWEEN '2015-01-07 18:09:45' and '2015-11-09 18:09:45' Error Code: 1064. 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 '' at line 26 0.0060 sec