Jump to content


Photo

problem in select


  • Please log in to reply
1 reply to this topic

#1 logu

logu
  • Members
  • PipPipPip
  • Advanced Member
  • 32 posts

Posted 13 September 2006 - 01:17 PM


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

#2 fenway

fenway
  • Staff Alumni
  • MySQL Si-Fu / PHP Resident Alien
  • 16,199 posts
  • LocationToronto, ON

Posted 13 September 2006 - 03:19 PM

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
Seriously... if people don't start reading this before posting, I'm going to consider not answering at all.




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users