Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2004

    Unanswered: Awkward MySQL select query...

    OKay I have delivery_tb

    Delivery ID - Int(6) - Primary Key - Auto Increment
    UserID - Int(6)
    CarID - Int(6)
    ManufacturerID - Int(6)
    Date - Timestamp
    Delivered - Enum(0,1)

    I need to to select a maximum of 20 rows per Unique ManufacturerID...
    I need to also select a maximum of 5 rows per Unique UserID per Unique ManufacturerID...

    So that no user can get more than 5 cars delivered per manufacturer per month...

    I'm using PHP5 as well...

  2. #2
    Join Date
    Nov 2004
    out on a limb
    Provided Answers: 59
    the group by & having clauses would be worth a look
    also the "top" sub clause eg "select top n from"

    dependiogn on what version of MySQL you are using you could enforce the no more than 5 cars a month rule using a teble level constraint

    does the coursework have to a PHP solution, a MySQL solution or a combined / overall solution?
    I'd rather be riding on the Tiger 800 or the Norton

  3. #3
    Join Date
    Oct 2004
    If I can get this to be an all-in-one query (i.e. not having to loop through PHP and perform multiple queries) then that is the ideal solution...

    I'll have a look through what you have suggested...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts