#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    2
    Rep Power
    0
    I have a table for news. I want to display two latest headlines from each
    category. Does anybody know how to do it in one query?

  2. #2
  3. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,648
    Rep Power
    4493
    The only way I can think of right now would be to do a seperate select statement for each category....

    Do you have an ID or a date in each row?

    ---John Holmes...

    ------------------
    *************************************************************
    * The manual can probably answer 90% of your questions...
    *
    * PHP Manual. www.php.net/manual
    * MySQL Manual: www.mysql.com/documentation/mysql/bychapter
    *************************************************************
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Oct 2000
    Posts
    2
    Rep Power
    0
    Well, it works alright in separate queries, but as we are trying to minimimize the number of queries per page this isn't the solution.

    The fields are currently following:
    id, headline, story, category, date

    Is it true that sub-selects are not supported in MySql?!
  6. #4
  7. Banned (not really)
    Devshed Supreme Being (6500+ posts)

    Join Date
    Dec 1999
    Location
    Brussels, Belgium
    Posts
    14,648
    Rep Power
    4493
    Yes, that's true.

Similar Threads

  1. How to exclude items in table
    By merlinmud in forum MySQL Help
    Replies: 2
    Last Post: January 7th, 2004, 11:25 PM
  2. counting records in category tree
    By midget4000x in forum MySQL Help
    Replies: 1
    Last Post: October 25th, 2003, 02:04 PM
  3. sorting by category
    By miseria in forum PHP Development
    Replies: 5
    Last Post: October 19th, 2003, 11:32 AM
  4. Give warning alert while selecting Option box
    By paCkeTroUTer in forum HTML Programming
    Replies: 6
    Last Post: September 25th, 2003, 02:02 PM
  5. Replies: 0
    Last Post: August 14th, 2003, 08:51 AM

IMN logo majestic logo threadwatch logo seochat tools logo