我正在尝试将名为“set”的MYSQL表中的列分组,并且我正在尝试检索该集合中最低的page_id。
SELECT * FROM pages WHERE project_id ='$project_id' GROUP BY `set` ORDER BY page_id ASC
我该如何正确地做到这一点?
答案 0 :(得分:3)
使用MIN()
聚合函数:
SELECT MIN(page_id) AS lowest_page_id
FROM pages
WHERE project_id ='$project_id'
GROUP BY `set`