Bram Raaijmakers Bram Raaijmakers - 2 months ago 7
MySQL Question

pdo GROUP BY query not returning all values

I'm building a website where users can bid other people's stuff (think eBay). Now I've finished the bidding function and want to give the owner some info about the users who bid, email, phone number etc. But I only want to display it once so that if a user bid's 5 times the owner doesn't see this users info 5 times.

I'm using the

GROUP BY
function but this only returns me 2 values but it should return 4 values.

This is the query i'm using:

$infoBiederStmt = $objDatabaseAds->prepare('SELECT * FROM bieden GROUP BY ownerid = :ownerid ORDER BY prijs DESC');


As far as I know there is nothing wrong with this query. If someone can help me out with this thanks in advance!

Answer

Binding to GROUP BY is not correct, do like below:-

$infoBiederStmt = $objDatabaseAds->prepare('SELECT * FROM bieden GROUP BY ownerid ORDER BY prijs DESC');
Comments