SitePoint Sponsor

User Tag List

Results 1 to 4 of 4

Hybrid View

  1. #1
    SitePoint Wizard
    Join Date
    Mar 2002
    Location
    Bristol, UK
    Posts
    2,240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    What's wrong with this query?

    Hi all,

    Just a simple error I hope [img]images/smilies/smile.gif[/img]

    What's wrong with this?

    SELECT * FROM blog GROUP BY date WHERE date LIKE '200305%' LIMIT 0 , 30

    This is the error I'm getting:

    You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'WHERE date LIKE '200305%' LIMIT 0, 30' at line 1

    Thanks [img]images/smilies/smile.gif[/img]

    -Sam
    Sam Hastings

  2. #2
    Hi there! Owen's Avatar
    Join Date
    Jan 2000
    Location
    CA
    Posts
    1,165
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Isn't date a reserved keyword? Try

    SELECT * FROM blog GROUP BY `date` WHERE `date` LIKE '200305%' LIMIT 0 , 30

    Owen

  3. #3
    SitePoint Wizard
    Join Date
    Mar 2002
    Location
    Bristol, UK
    Posts
    2,240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hi Owen,

    I've tried what you suggested - but no joy. The error is still there.

    Thanks anyway

    -Sam
    Sam Hastings

  4. #4
    SitePoint Wizard
    Join Date
    Mar 2002
    Location
    Bristol, UK
    Posts
    2,240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ahhhh, just realised another of those silly mistakes

    You can't use WHERE with GROUP BY, you have to use HAVING instead

    Damn!

    -Sam
    Sam Hastings


Bookmarks

Posting Permissions

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