logu Posted September 13, 2006 Share Posted September 13, 2006 Hai, I am having two tables "user" and "loan" user can have n number of loans . what i want is to select the user who has more than five records in loan table. is it possible ? thanks in advance Quote Link to comment Share on other sites More sharing options...
fenway Posted September 13, 2006 Share Posted September 13, 2006 Just a wild guess, based on arbitrary field names:SELECT username, COUNT(*) AS cnt FROM user INNER JOIN loan ON ( user.uid = loan.user_uid ) GROUP BY user.uid HAVING cnt >= 5 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.