DB中的结果:
TID - message
1 - hi
1 - bye
2 - hi
2 - hi
2 - bye
说明:
$new = $pdo->prepare("SELECT * FROM mybb_posts ORDER BY pid ASC LIMIT 1");
我不想两次获取相同的ID,只需要一次。
所以它会获取:
1 - hi
和2 - hi
。
我该怎么做?
答案 0 :(得分:1)
thx为您的评论,编辑了我的帖子:
$new = $pdo->prepare("SELECT * FROM mybb_posts GROUP BY pid ORDER BY pid");
或
$new = $pdo->prepare("SELECT DISTINCT(pid) FROM mybb_posts ORDER BY pid");
答案 1 :(得分:1)
我猜这有效:
$new = $pdo->prepare("SELECT * FROM mybb_posts GROUP BY pid ORDER BY pid ASC");
在phpMyAdmin中测试时,它会返回:
PID - message
1 - hi
2 - hi