Hello
I am new to SQL and I ran into a small syntax problem
I am trying to run the following SQL query which results in a syntax error which I cannot find:
SELECT COUNT(*) FROM individual_tbl WHERE (Last_name LIKE '%na%' AND ID IN (SELECT ID, Last_name FROM individual_tbl WHERE (Last_name LIKE 'N%')));
Here is the definition of individual_tbl:
CREATE TABLE `individual_tbl` (
`ID` int(11) unsigned NOT NULL auto_increment,
`Last_name` varchar(100) default '',
PRIMARY KEY (`ID`)
) TYPE=MyISAM;
can anyone see the problem?
help with SQL syntax error
Moderator: General Moderators
-
davidklonski
- Forum Contributor
- Posts: 128
- Joined: Mon Mar 22, 2004 4:55 pm
-
davidklonski
- Forum Contributor
- Posts: 128
- Joined: Mon Mar 22, 2004 4:55 pm
-
davidklonski
- Forum Contributor
- Posts: 128
- Joined: Mon Mar 22, 2004 4:55 pm
- andre_c
- Forum Contributor
- Posts: 412
- Joined: Sun Feb 29, 2004 6:49 pm
- Location: Salt Lake City, Utah
Unfortunately, it will take two statements: create temp table, select what you need:
... then use that table on your select statement. The table will be deleted when the connection is closed
Code: Select all
CREATE TEMPORARY TABLE temp_table SELECT id, last_name FROM ... etc.