Hi Everyone,
This is my first post to the forum, thank you in advance for your time and help. I've got an exam scheduling application that's hooking into a SQL server database for a class. I'm trying to run the following command:
statement = connection.createStatement();
statement.executeQuery("select count(instructor_in_both_blocks.inst_id)"
+ "from(select distinct(bsOne.instructor_id) inst_id"
+ " FROM block_staging_one bsOne, block_staging_one bsOneTwo"
+ " where bsOne.schedule_group = " + blockUnderQuestion + "and bsOne.instructor_id = bsOneTwo.instructor_id"
+ "and bsOneTwo.schedule_group =" + comparisonBlock + ") instructor_in_both_blocks;");
Where blockUnderQuestion and comparisonBlock are both simple int's that I'm passing into the SQL Query. When I run this command, NetBeans is throwing the following error:
Apr 23, 2012 10:13:19 AM backend.ERSMain assignScheduleBlock
SEVERE: null
com.microsoft.sqlserver.jdbc.SQLServerException: Incorrect syntax near 'bsOneTwo'.
Is there something I'm missing about SQL syntax for
java? I can run the exact same syntax in an SQL editor and it returns without issue.
Thanks for your time!
Jonathan