我有两个表calldetails和calltype
calldetails表

id calltype isactive
1   1       1
2   1       1
3   1       1

调用类型表
id name             isactive
1  mobile internet   1

预期结果
id name             isactive
1  mobile internet   1

但我的成绩低于
id name             isactive
1  mobile internet   1
1  mobile internet   1
1  mobile internet   1

我使用了下面的查询
SELECT ct.`name` , ct.`id`
FROM calltype AS ct
INNER JOIN calldetails AS cd ON cd.`isactive` =1
WHERE ct.`isactive` =1
AND ct.`id` = cd.`calltype`
LIMIT 0 , 30

如何使用内部联接获取单个值。

最佳答案

尝试使用DISTINCT

SELECT DISTINCT ct.`name` , ct.`id`
FROM calltype AS ct
INNER JOIN calldetails AS cd ON cd.`isactive` =1
WHERE ct.`isactive` =1
AND ct.`id` = cd.`calltype`
LIMIT 0 , 30

关于php - 使用内部联接获取单个值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/25988003/

10-11 01:25