SitePoint Sponsor

User Tag List

Results 1 to 5 of 5
  1. #1
    SitePoint Guru
    Join Date
    Sep 2004
    Location
    Provo, UT
    Posts
    865
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Getting an error message on an inner join

    When I try to run the following query I get the error, "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 'FROM' at line 5"

    Any ideas?

    Thanks!


    PHP Code:
    SELECT
       u
    .uID,
       
    u.last,
       
    l.loginDate,
     
    FROM users u
    INNER
     JOIN logins l
       ON u
    .uID l.uID
    WHERE
      l
    .loginDate >= u.last
    GROUP BY
     u
    .uID
    ORDER BY u
    .last
      limit 1000

    Convert your dollars into silver coins. www.convert2silver.com

  2. #2
    SitePoint Evangelist
    Join Date
    Jun 2007
    Location
    North Yorkshire, UK
    Posts
    483
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    loginDate is followed by a comma - should not be there

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,341
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    and that error would be a lot harder to make using the leading comma convention --
    Code:
    SELECT u.uID
         , u.last
         , l.loginDate
         ,  
      FROM users u
    ...
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  4. #4
    Non-Member
    Join Date
    Apr 2004
    Location
    Miami, FL, USA
    Posts
    448
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937 View Post
    and that error would be a lot harder to make using the leading comma convention
    But that's such an ugly way to code SQL.

  5. #5
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,341
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    ugly is in the eye of the beholder

    do a forum search, you will find a half dozen threads where someone made the same error, then the leading comma convention was brought up, then someone new was converted

    you, too, will see the light one day
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •