java - Can't figure out why this big double inner join isn't working, but when split it does -


here queries split work fine...

    string sqlstatement = "select wblinkwebsiteid, wblinkcategoryparentid, wblinktitle, wblinkurl websitecategory_table wblinkcategoryid = ?";     string[] args = { categorysubid }; 

part 2

    sqlstatement = "select locations_table.locationwebsiteid, " + "locations_table.locationcity, " + "locations_table.locationstate, " + "locations_table.locationcountry, locations_table.locationtype, " + "locations_table.locationurl, " + "pref_table.pref_savedtitle " + "from pref_table inner join " + "locations_table on pref_table.pref_locationid = locations_table.locationid " + "where " + "pref_table.pref_savedtitle = '" + thesavedpref + "' order locations_table.locationstate, locations_table.locationcity"; 

now here attempt combine 2 instead of having 2 go in row back , burn time/resources...

    string newsqlstatement = "select locations_table.locationwebsiteid, " + "locations_table.locationcity, " + "locations_table.locationstate, "       + "locations_table.locationcountry, " + "locations_table.locationurl, " + "locations_table.locationid, " + "pref_table.pref_savedtitle, "    + "websitecategory_table.wblinktitle, " + "websitecategory_table.wblinkurl " + "from pref_table inner join "    + "locations_table on pref_table.pref_locationid = locations_table.locationid " + "inner join websitecategory_table " + "on websitecategory_table.wblinkwebsiteid = pref_table.pref_websiteid " + "where " + "pref_table.pref_savedtitle = '" + thesavedpref + "'"; 

now when try "single" way keeps returning whole database of locations in locations_table query. doesn't exact ones need.

i know query works, because have tested here: http://sqlfiddle.com/#!6/ede97/2

now know example on sqlfiddle using ms server 2014, assumed syntax should pretty same since standard select inner joins, wrong?

anyone know i'm doing wrong? appreciated

edit - fixed sqlfiddle, put wrong statement in example

aren't missing filter on wblinkcategoryid in combined query. shouldn't have this:

... + "inner join websitecategory_table " + "on websitecategory_table.wblinkwebsiteid = pref_table.pref_websiteid " + "where " + "websitecategory_table.wblinkcategoryid in (<value1>,...,<valuen>) , " + "pref_table.pref_savedtitle = '" + thesavedpref + "'";


Comments

Popular posts from this blog

Java 8 + Maven Javadoc plugin: Error fetching URL -

css - SVG using textPath a symbol not rendering in Firefox -

python - Subprocess.CREATE_NEW_CONSOLE -