- 溶液 -
SELECT Table1.unvan, Table2.sayi FROM
(SELECT id , unvan FROM unvan WHERE id IN
(SELECT unvani FROM personel WHERE gorev_yeri IN
(SELECT id FROM gorev_yeri WHERE il_id="34") ) ) AS Table1
JOIN
( SELECT unvani as id , count(*) AS sayi FROM personel WHERE gorev_yeri IN (SELECT id FROM gorev_yeri WHERE il_id="34") GROUP BY unvani ) AS Table2
ON Table1.id = Table2.id
我有2个查询,我想加入他们。
SELECT id
, unvan
FROM unvan
WHERE id IN (SELECT unvani
FROM personel
WHERE gorev_yeri IN (SELECT id
FROM gorev_yeri
WHERE il_id="34")
)
SELECT unvani as id
, count(*) AS sayi
FROM personel
WHERE gorev_yeri IN (SELECT id
FROM gorev_yeri
WHERE il_id="34") GROUP BY unvani
我需要这个:
unvan |卅一
-------- | ----
答案 0 :(得分:1)
(SELECT id ,unvan 来自unvan WHERE id IN(SELECT unvani 来自个人 在哪里gorev_yeri IN(SELECT id 来自gorev_yeri WHERE il_id =“34”) ) )表1
加入
( SELECT unvani as id,count(*)AS sayi FROM personel WHERE gorev_yeri IN(SELECT id FROM gorev_yeri WHERE il_id =“34”)GROUP BY unvani )表2
on table1.id = table2.id;
答案 1 :(得分:1)
基于提供的错误
应该是这样的:
SELECT `Table1`.unvan, `Table2`.id
FROM
(
SELECT id
, unvan
FROM unvan
WHERE id IN (SELECT unvani
FROM personel
WHERE gorev_yeri IN (SELECT id
FROM gorev_yeri
WHERE il_id="34")
)
) AS `Table1`
JOIN
(
SELECT unvani as id
, count(*) AS sayi
FROM personel
WHERE gorev_yeri IN (SELECT id
FROM gorev_yeri
WHERE il_id="34") GROUP BY unvani
) AS `Table2`
ON `Table1`.id = `Table2`.id