SQL masters:

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Zester
    Confirmed User
    • Jul 2003
    • 5344

    #1

    SQL masters:

    What is wrong with this Sub Query:
    Code:
    SELECT date 
    FROM  `records` 
    WHERE  STATUS  =  'published' 
    AND date = ( select max(date) FROM `records` )
    LIMIT = 25;
    it's suppose to spit out the date of the latest 25 articles in 'published' status and nothing more.
    Last edited by Zester; 02-09-2006, 02:58 AM.
    * Mainstream ? $65 per sale
    * new male contraception
  • everestcash
    Confirmed User
    • Apr 2002
    • 2194

    #2
    i was thinking, is there a way to rewrite that query using 'order by id' or 'date' instead, without using a sub query. That'll be a simpler approach.

    like

    select from `records` where status = 'published' order by id desc limit 0, 25;

    Comment

    • ddfGandalf
      Confirmed User
      • Feb 2005
      • 534

      #3
      select date from records where status='published' order by date desc LIMIT 25;

      Comment

      • woj
        <&(©¿©)&>
        • Jul 2002
        • 47882

        #4
        Originally posted by everestcash
        select from `records` where status = 'published' order by id desc limit 0, 25;
        Custom Software Development, email: woj#at#wojfun#.#com to discuss details or skype: wojl2000 or gchat: wojfun or telegram: wojl2000
        Affiliate program tools: Hosted Galleries Manager Banner Manager Video Manager
        Wordpress Affiliate Plugin Pic/Movie of the Day Fansign Generator Zip Manager

        Comment

        • Pryda
          Confirmed User
          • Dec 2005
          • 906

          #5
          Originally posted by Zester
          What is wrong with this Sub Query:
          Code:
          SELECT date 
          FROM  `records` 
          WHERE  STATUS  =  'published' 
          AND date = ( select max(date) FROM `records` )
          LIMIT = 25;
          it's suppose to spit out the date of the latest 25 articles in 'published' status and nothing more.

          Your query wants up to 25 record dates for articles published on the same date as the most recent record (published or not).
          Babepedia

          Comment

          • sickbeatz
            The Hustler
            • Feb 2005
            • 4993

            #6
            SELECT date
            FROM `records`
            WHERE STATUS = 'published' ORDER BY date DESC LIMIT 25;

            GalleryFeeder.com

            Comment

            Working...