Jump to content

Recommended Posts

(SELECT * FROM CLASSES_areas WHERE LENGTH(state1)>0) UNION (SELECT * FROM CLASSES_ares WHERE LENGTH(state2)>0)

 

I am getting a syntax error right after UNION, what is wrong with this query?

 

Here is the tables structure:

CREATE TABLE `CLASSES_areas` (
  `id` int(11) NOT NULL auto_increment,
  `areaname` varchar(100) NOT NULL default '',
  `shortname` varchar(50) NOT NULL default '',
  `state1` varchar(5) NOT NULL default '',
  `state2` varchar(5) NOT NULL default '',
  `state3` varchar(5) NOT NULL default '',
  PRIMARY KEY  (`id`)
) TYPE=MyISAM AUTO_INCREMENT=4 ;

 

Any help would be really appreciated.

 

Thanks,

mb81

Link to comment
https://forums.phpfreaks.com/topic/63071-what-is-wrong-with-this-query/
Share on other sites

You refer to the table CLASSES_ares in the 2nd SELECT statement , This should be CLASSES_areas

 

Yes, I realized that once I posted it. There is, however, still a syntax error on the word UNION.

 

Here is the code and the error again:

SELECT * FROM CLASSES_areas WHERE LENGTH( state1 ) >0 UNION SELECT * FROM CLASSES_areas WHERE LENGTH( state2 ) >0 

 

MySQL said: Documentation

#1064 - You have an error in your SQL syntax near 'UNION SELECT * FROM CLASSES_areas WHERE LENGTH( state2 ) > 0' at line 1

 

It doesn't seem to matter what I include in parenthesis, even though that the MySQL 5.0 documentation said I should include the entire SELECT statement in parenthesis

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.