Reputation: 979
Results in DB:
TID - message
1 - hi
1 - bye
2 - hi
2 - hi
2 - bye
Statement:
$new = $pdo->prepare("SELECT * FROM mybb_posts ORDER BY pid ASC LIMIT 1");
I don't want to fetch the same ID twice, only once.
So it will fetch:
1 - hi
and 2 - hi
.
How do I do so?
Upvotes: 0
Views: 131
Reputation: 6693
thx for your comment, edited my post:
$new = $pdo->prepare("SELECT * FROM mybb_posts GROUP BY pid ORDER BY pid");
or
$new = $pdo->prepare("SELECT DISTINCT(pid) FROM mybb_posts ORDER BY pid");
Upvotes: 1
Reputation: 572
I guess this works:
$new = $pdo->prepare("SELECT * FROM mybb_posts GROUP BY pid ORDER BY pid ASC");
When tested in phpMyAdmin it returns:
PID - message
1 - hi
2 - hi
Upvotes: 1