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.
我正在尝试查询我的数据库并为每个数据库返回一个名称。(PHP/MySQL)
表中的示例数据: Mary Tim Mary Rick Tim Mary Rick
我想知道如何只获取每个名称一次并显示它们。而不是多次循环并抓取和显示所有名称。
提前致谢!坦率
这就是 DISTINCT 运算符的作用:
SELECT DISTINCT(`name`) from `users`;
SELECT DISTINCT column_name(s) FROM table_name