waynew Posted July 10, 2008 Share Posted July 10, 2008 I keep getting 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 id FROM jobs WHERE status = 1 AND MONTH(reg_date) = '10'' at line 2 $i=0; //reset counter while($i < sizeof($x_months)){ $profit_result[$i] = mysql_query("SELECT SUM(tender_price) FROM tenders WHERE job_id = SELECT id FROM jobs WHERE status = 1 AND MONTH(reg_date) = '$months_timeline[$i]'") or die(mysql_error()); $i++; } What's wrong????! Link to comment https://forums.phpfreaks.com/topic/114061-sql-syntax-error/ Share on other sites More sharing options...
atticus Posted July 10, 2008 Share Posted July 10, 2008 Have you tried running the sub query in parenthesis? Link to comment https://forums.phpfreaks.com/topic/114061-sql-syntax-error/#findComment-586241 Share on other sites More sharing options...
atticus Posted July 10, 2008 Share Posted July 10, 2008 Have you tried running the sub query in parenthesis? SELECT SUM(tender_price) FROM tenders WHERE job_id = (SELECT id FROM jobs WHERE status = 1 AND MONTH(reg_date) = '$months_timeline[$i]') Link to comment https://forums.phpfreaks.com/topic/114061-sql-syntax-error/#findComment-586265 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.