I have the following table join that runs fine in Microsoft SQL Server and returns the expected results.
SELECT d.id1, c.content_type FROM Document2 AS d INNER JOIN Content2 AS c ON d.content_id = c.content_id WHERE (d.class_id = 1) However when I place the statement into a ColdFusion CFC, the statement will not execute and I am not getting anything to return. Does the syntax change within the CFC file? Is the Microsoft SQL syntax different from the ColdFusion CFC syntax? Or am I missing something else here?
This is the relevant function. I can get this code to work if I use a simple SQL statement that is not a table join. However, when I insert the table join statement nothing will return.
remote array function getcontent() { var q = new com.adobe.coldfusion.query(); q.addParam( name="searchParam", value="#searchName#" ); q.setDatasource("Document"); q.setSQL("SELECT d.id1, c.content_type FROM Document2 AS d INNER JOIN Content2 AS c ON d.content_id = c.content_id WHERE (d.class_id = 1)"); var data = q.execute().getResult(); var result = []; for(var i=1; i<= data.recordCount; i++) { arrayAppend(result, {"id"=data.d.id1[i], "Type"=data.c.content_type[i]}); } return result; }