SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: limit

  1. #1
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    limit

    There is a syantax error with the following statement

    $result= mysql_query("SELECT * FROM articles, lookup, writers ORDER BY published DESC LIMIT $offset,1 WHERE lookup.aid = articles.aid AND lookup.wid = writers.wid");

    It looks fine? is the limit in the wrong place? I tried moving it around, but it still didnt work


    thanx

  2. #2
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    It sure is, have a look here for the rundown http://mysql.he.net/documentation/my...ce.html#SELECT

    Should be:
    $result= mysql_query("SELECT * FROM articles, lookup, writers ORDER BY published DESC WHERE lookup.aid = articles.aid AND lookup.wid = writers.wid LIMIT $offset,1");
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  3. #3
    SitePoint Guru
    Join Date
    Apr 2001
    Location
    BC, Canada
    Posts
    630
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Im still getting this error:



    articlefsdfsdaYou have an error in your SQL syntax near 'WHERE lookup.aid = articles.aid AND lookup.wid = writers.wid LIMIT 2,1' at line 1

  4. #4
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Did you read the link I posted, if you did you would have noticed that your ORDER BY clause needs to go after your WHERE clause as well.

    Staright from mysql.com
    SELECT [STRAIGHT_JOIN] [SQL_SMALL_RESULT] [SQL_BIG_RESULT] [SQL_BUFFER_RESULT]
    [HIGH_PRIORITY]
    [DISTINCT | DISTINCTROW | ALL]
    select_expression,...
    [INTO {OUTFILE | DUMPFILE} 'file_name' export_options]
    [FROM table_references
    [WHERE where_definition]
    [GROUP BY {unsigned_integer | col_name | formula} [ASC | DESC], ...]
    [HAVING where_definition]
    [ORDER BY {unsigned_integer | col_name | formula} [ASC | DESC] ,...]
    [LIMIT [offset,] rows]
    [PROCEDURE procedure_name]
    [FOR UPDATE | LOCK IN SHARE MODE]]
    Please don't PM me with questions.
    Use the forums, that is what they are here for.

  5. #5
    ********* Callithumpian silver trophy freakysid's Avatar
    Join Date
    Jun 2000
    Location
    Sydney, Australia
    Posts
    3,798
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    ...as opposed to your previous post

  6. #6
    Dumb PHP codin' cat
    Join Date
    Aug 2000
    Location
    San Diego, CA
    Posts
    5,460
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hey I can't find allthe booboos in one glance it hurts my eyes So I figured once he read the page at mysql.com on the order of the args in a select statement, he would have seen his second error
    Please don't PM me with questions.
    Use the forums, that is what they are here for.


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
  •