如何仅选择3行:
63518 | 3 | 338 | 338 - Turks and .... | 0.0245 |
63519 | 3 | 338 | 338 - Jamica | 0.0235 |
63522 | 3 | 338 | 338 - Haiti | 0.0285 |
SELECT
r.id,
r.client_id,
mcc.mcc AS mcc,
CONCAT(mcc.mcc, " - ", mcc.country_name) AS mcc_text,
r.rate,
mcc.dial_code,
r.active
FROM rates r
INNER JOIN clients c
ON c.id = r.client_id
INNER JOIN mcc
ON mcc.mcc = r.mcc
WHERE r.client_id = 3 AND r.mcc = 338 AND r.mnc = 50 AND r.active = 1
我试着用
.... GROUP BY r.id
但是mcc_text错了
答案 0 :(得分:0)
试试这个:
SELECT DISTINCT
r.id,
r.client_id,
mcc.mcc AS mcc,
CONCAT(mcc.mcc, " - ", mcc.country_name) AS mcc_text,
r.rate,
mcc.dial_code,
r.active
FROM rates r
INNER JOIN clients c
ON c.id = r.client_id
INNER JOIN mcc
ON mcc.mcc = r.mcc
WHERE r.client_id = 3 AND r.mcc = 338 AND r.mnc = 50 AND r.active = 1
答案 1 :(得分:0)
尝试此查询可能有效
SELECT DISTINCT
r.id,
r.client_id,
mcc.mcc AS mcc,
CONCAT(mcc.mcc, " - ", mcc.country_name) AS mcc_text,
(SELECT rate FROM rates WHERE rates.id=r.id)AS rate,
mcc.dial_code,
r.active
FROM rates r
INNER JOIN clients c
ON c.id = r.client_id
INNER JOIN mcc
ON mcc.mcc = r.mcc
WHERE r.client_id = 3 AND r.mcc = 338 AND r.mnc = 50 AND r.active = 1
GROUP BY r.id