Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我的表如下所示:
id name 1 nice 2 nice 3 nice 4 nicest 5 nicest
有一个像这样的选择语句SELECT * FROM table WHERE name LIKE '%nice%'显示所有 5 行。如果名称相同,我试图让它只显示一次该行。
SELECT * FROM table WHERE name LIKE '%nice%'
运行后会显示如下的选择 sql:
id name 1 nice 4 nicest
SELECT min(id) AS id, name FROM TABLE WHERE name LIKE '%nice%' GROUP BY name
在“SELECT”之后添加“DISTINCT”命令。
来源/使用/示例