dredge Posted October 23, 2003 Share Posted October 23, 2003 Hello, I\'m new to SQL and have run across a problem. First of all, here is the complete SQL code that results in an error: SELECT WC_First_Name, WC_Last_Name, WC_SSN, WC_Availability_Type FROM Worker_Client WHERE WC_City = \'Sacramento\' AND WC_State = \'CA\' AND WC_HS_Status = 1 AND WC_College_Status = 2 AND WC_SSN IN(SELECT WC_SSN FROM WC_Skill Where Skill_ID IN(\'1166\',\'1198\',\'1180\')) AND WC_SSN IN(SELECT WC_SSN FROM WC_Certificate Where Certificate_ID IN(\'1001\',\'1003\',\'1007\',\'1008\')) When I run this code, I get this error: MySQL said: You have an error in your SQL syntax near \'SELECT WC_SSN FROM WC_Skill WHERE Skill_ID IN ( \'1166\', \'1198\', \'1180\' ) ) AN\' at line 5 The weird thing is that this code works fine when I exchange the insides of the two IN Statements with a test number like \'1004\'. For example, this code works: SELECT WC_First_Name, WC_Last_Name, WC_SSN, WC_Availability_Type FROM Worker_Client WHERE WC_City = \'Sacramento\' AND WC_State = \'CA\' AND WC_HS_Status = 1 AND WC_College_Status = 2 AND WC_SSN IN ( \'1004\' ) AND WC_SSN IN ( \'1004\' ) Another weird thing is that the code that I just took out in the previous example runs fine on its own. For example, these two pieces of code (from inside the IN Statements) works just fine by themselves: SELECT WC_SSN FROM WC_Skill WHERE Skill_ID IN ( \'1166\', \'1198\', \'1180\' ) SELECT WC_SSN FROM WC_Certificate WHERE Certificate_ID IN ( \'1001\', \'1003\', \'1007\', \'1008\' ) I am using PHP 4.1.2 and MySQL 3.23.39 Thanks in advance. : ) Quote Link to comment https://forums.phpfreaks.com/topic/1216-help-please-in-statement-not-working/ Share on other sites More sharing options...
Barand Posted October 23, 2003 Share Posted October 23, 2003 You need version 4.1 of MySql to be able to use subqueries. Quote Link to comment https://forums.phpfreaks.com/topic/1216-help-please-in-statement-not-working/#findComment-4066 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.