If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Problem using a Nested Query on MySQL v 3.23.55

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 04-03-04, 10:02
martin_katz martin_katz is offline
Registered User
 
Join Date: Apr 2004
Posts: 2
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
Reply With Quote
  #2 (permalink)  
Old 04-03-04, 12:52
r937 r937 is offline
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,534
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
Quote:
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
__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #3 (permalink)  
Old 04-03-04, 13:35
martin_katz martin_katz is offline
Registered User
 
Join Date: Apr 2004
Posts: 2
thanks!!
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On