So you want 5 contacts for every user? Try this: SELECT COUNT(c.id) AS count, u.username, u.first_name, u.last_name, c.name FROM user AS u, contact AS c WHERE u.id = c.id_user GROUP BY c.id_user HAVING count <= 5
Jerry Swanson wrote: >How to select 5 records(including username, first_name, last_name, >contact) for each user in the database? > >table user( > id, > username, > first_name, > last_name >) > >contact( > id > id_user //id from user table > name >) > > > -- MySQL General Mailing List For list archives: http://lists.mysql.com/mysql To unsubscribe: http://lists.mysql.com/[EMAIL PROTECTED]