我有一张这样的表:
---------------------
| id | code | total |
---------------------
| 1 | AA01 | 5 |
| 2 | AA01 | 10 |
| 3 | AA01 | 7 |
| 4 | AA02 | 3 |
| 5 | AA02 | 1 |
---------------------
如果看起来像这样创建一个MySQL查询:
--------
| code |
--------
| AA01 |
| AA02 |
--------
我尝试了以下查询:
SELECT * FROM `buckets` WHERE `code` = 'FFF071214095758' or `code` = 'FFF071214101258'
但显示的是整个记录。我只需要 显示每个代码只有一个具有相同代码的记录。 MySql查询可以做到吗?
答案 0 :(得分:0)
你可能要么:
SELECT code
FROM `buckets`
WHERE `code` = 'AA01'
OR `code` = 'AA02'
GROUP BY code
或:
SELECT DISTINCT code
FROM `buckets`
WHERE `code` = 'AA01'
OR `code` = 'AA02'
答案 1 :(得分:0)
你可以试试......
SELECT DISTINCT code
FROM `buckets`
WHERE `kode_transaksi` = 'FFF071214095758' or `kode_transaksi` = 'FFF071214101258'