Mysql Limit column value repetition N times
Posted
by Paper-bat
on Stack Overflow
See other posts from Stack Overflow
or by Paper-bat
Published on 2010-06-14T14:22:08Z
Indexed on
2010/06/14
15:02 UTC
Read the original article
Hit count: 198
Hi at all, is my first question here, so be patient ^^
I'll go directly to problem, I have two table Customer (idCustomer, ecc.. ecc..) Comment (idCustomer, idComment, ecc.. ecc..)
obviosly the two table are joined togheter, for example
SELECT * FROM Comment AS co
JOIN Customer AS cu ON cu.idCustomer = co.idCustomer
With this I select all comment from that table associated with is Customer, but now I wanna limit the number of Comment by 2 max Comment per Customer.
The first thing I see is to use 'GROUP BY cu.idCustomer' but it limit only 1 Comment per Customer, but I wanna 2 Comment per Customer..
how now to proceed?
© Stack Overflow or respective owner