Results 1 to 3 of 3
  1. #1
    Join Date
    Apr 2004
    Posts
    2

    Unanswered: Problem using a Nested Query on MySQL v 3.23.55

    Hi,
    I got kinda lost here....
    I tried to use the following nested query on MySQL v 3.23.55:

    SELECT id_paquete,nro_seq
    FROM Paquete AS P
    WHERE P.id_paquete >= ALL (SELECT id_paquete FROM Paquete)

    and the answer was:

    You have an error in your SQL syntax near 'ALL ( SELECT id_paquete FROM Paquete )

    The query

    SELECT id_paquete
    FROM Paquete

    works just fine.

    The MySQL OnLine Manual (http://www.mysql.com/doc/en/ALL_subqueries.html) suggests it should work..

    any clue?
    thanks
    Martin

  2. #2
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    the page you cited --
    http://www.mysql.com/doc/en/ALL_subqueries.html

    is part of a larger section on subqueries

    if you go up to this page --
    http://www.mysql.com/doc/en/Subqueries.html

    it says
    Starting with MySQL 4.1, all subquery forms and operations that the SQL standard requires are supported, as well as a few features that are MySQL-specific.

    With earlier MySQL versions it was necessary to work around or avoid the use of subqueries

    For MySQL versions prior to 4.1, most subqueries can be successfully rewritten using joins and other methods. See section 14.1.8.11 Rewriting Subqueries for Earlier MySQL Versions.
    so you want this --
    PHP Code:
    select P.id_paquete
         
    P.nro_seq 
      from Paquete 
    as 
    inner
      join Paquete 
    as P2
        on P
    .id_paquete >= P2.id_paquete
    group
        by P
    .id_paquete
         
    P.nro_seq 
    having P
    .id_paquete max(P2.id_paquete
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  3. #3
    Join Date
    Apr 2004
    Posts
    2
    thanks!!

Posting Permissions

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