ERROR 1064: You have an error in your SQL syntax....

2005-04-08 Thread Chuzo Okuda
I am a newbie here. I created a simple table defined as:
create table test (
  testID   int unsigned not null auto_increment,
  testName varchar(128) not null,
  primary key (testID)
) type = MyISAM;
Now, I filled out test table, and looking for the testName with max 
characters.

The following caused the same error of:
ERROR 1064: 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 'select max(length(testName)) from test)' at line 1

select testName from test where length(testName) = (select 
max(length(testName)) from test);

Then I copied a simple line from MySQL book:
select * from president where birth = (select min(birth) from president);
and adapted to my table with:
select * from test where testName = (select min(testName) from test);
and executed it with exactly the same error result.
MySQL version I am using is: 4.0.21-standard
Please help me why I get this error.
Thank you
Chuzo
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]


Re: ERROR 1064: You have an error in your SQL syntax....

2005-04-08 Thread Peter Brawley
Chuzo,
SELECT MAX(LENGTH(...)) FROM ... ought to work.
SQL doesn't allow aggregate funcs like MAX() in the WHERE clause. Use 
HAVING().

For nested queries like SELECT ... WHERE colvalue=(SELECT...) you need 
version 4.1 or later.

Peter Brawley
http://www.artfulsoftware.com
-
Chuzo Okuda wrote:
I am a newbie here. I created a simple table defined as:
create table test (
  testID   int unsigned not null auto_increment,
  testName varchar(128) not null,
  primary key (testID)
) type = MyISAM;
Now, I filled out test table, and looking for the testName with max 
characters.

The following caused the same error of:
ERROR 1064: 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 'select max(length(testName)) from test)' at line 1

select testName from test where length(testName) = (select 
max(length(testName)) from test);

Then I copied a simple line from MySQL book:
select * from president where birth = (select min(birth) from president);
and adapted to my table with:
select * from test where testName = (select min(testName) from test);
and executed it with exactly the same error result.
MySQL version I am using is: 4.0.21-standard
Please help me why I get this error.
Thank you
Chuzo

--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.308 / Virus Database: 266.9.5 - Release Date: 4/7/2005
--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:http://lists.mysql.com/[EMAIL PROTECTED]