1

I have two MySQL Tables. user_tbl storing details of users and feedback_tbl stores feedback about them. Following is the Table Structure.

user_tbl


user_id

user_name

user_pic

mgr_id

business_unit

feedback_tbl


feedback_id

emp_id

feedback (varchar)

rating

date_info (datetime)


Note : emp_id in feedback_tbl is foreign key mapping to user_id in user_tbl

The result I need to have is take latest feedback of 3 users in each business_unit field. I have used query,

SELECT * FROM (SELECT u.user_id, u.user_name, u.user_pic,    u.business_unit, f.feedback, f.rating,f.date_info 
FROM user_tbl AS u , feedback_tbl AS f 
WHERE u.user_id = f.emp_id ORDER BY f.date_info DESC) AS t 
GROUP BY t.business_unit, t.user_id 

to get latest feedback of users in each business_unit. But this query gives me more rows of data for each business_unit as I'm having more than 10 users. So How can limit 3 user feedback for each business_unit ? Any Help?

0 Answers0