Encountered "(. Incorrect Select Statement, Expecting a 'FROM', But Encountered '(' Instead, A Select Statement Should Have a 'FROM' Construct.

Posted June 30, 2006 at 12:08 PM by Ben Nadel

Tags: ColdFusion, SQL

I was testing some ColdFusion Query of Queries functionality when I got this error:

Query Of Queries syntax error.
Encountered "(. Incorrect Select Statement, Expecting a 'FROM', But Encountered '(' Instead, A Select Statement Should Have a 'FROM' Construct.

I know what was causing the error because I was testing to see if something worked, but it's not the most obvious error. I guess it's a syntax error (from a technical standpoint), but in my case, where I was testing to see if ISNULL() worked, I'm really using a function that is not available.

That being said, if you get the error above, it means you are using something in the SELECT statement that is not allowed. If you are coming over from SQL, make sure you are not trying to use any SQL functions that are not available in the ColdFusion Query of Queries. As a foot note, here are some common SQL functions that I use that are not available in the ColdFusion Query of Queries:

ISNULL()
LEN()
DATEADD()



Reader Comments

Mar 31, 2007 at 11:25 PM // reply »
21 Comments

Hrm...

In my case, I have an XML file which I'm converting into a query object. The resulting query has a column named date. I can select * just fine, but when I specify the date column it blows up. Leave that column out and it works just fine. I've tried bracketing the column name, quoting it bracketing AND quoting to no avail.

Anyone have any ideas?


Mar 31, 2007 at 11:43 PM // reply »
21 Comments

Okay...

In this case, the solution was ot both bracket AND alias the questionable column. So this works:

SELECT [date] AS thedate
FROM QofQ


Apr 1, 2007 at 9:37 AM // reply »
10,640 Comments

Exactly... in fact, the same thing would apply to a regular non-query-of-queries SQL statement.


Oct 3, 2007 at 10:53 AM // reply »
4 Comments

I've run into this error as well using the COUNT function. It only works when i have just the function in the SELECT list and use no alias which is worthless for my purposes.


Mar 22, 2010 at 7:21 AM // reply »
6 Comments

I got this exception now.
In case you're using var-es local struct, CF gives you couple of "new" exceptions:

Encountered "local.

and

Encountered "id. Incorrect Select List, Incorrect select column

This is the way out:

<cfset var local = structNew() >
<cfset local.query = something... >
<cfquery name="local.queryOfQueries" dbtype="query" >
SELECT [id],
[columnId]
FROM [local].query
WHERE [columnId] IN ( ...cfqueryparam list output...)
ORDER BY [id] ASC
</cfquery>

Those who work with MS SQL Server should recognize this syntax.


Mar 22, 2010 at 6:40 PM // reply »
10,640 Comments

@Zarko,

Yeah, the [local] notation still trips me up from time to time.


May 4, 2010 at 3:25 PM // reply »
5 Comments

Ben,

You consistently give excellent explanations to most of the problems I have. Thank you for your service to the CF community!


May 4, 2010 at 3:30 PM // reply »
10,640 Comments

@Kate,

Thanks Kate! Hey, you going to CFUnited this year?


May 4, 2010 at 3:32 PM // reply »
5 Comments

Wouldn't miss it. See you there!


May 4, 2010 at 3:42 PM // reply »
10,640 Comments

Woohooo!


Post A Comment

Comment Etiquette: Please do not post spam. Please keep the comments on-topic. Please do not post unrelated questions or large chunks of code. And, above all, please be nice to each other - we're trying to have a good conversation here.

Please review the following issues:

Author Name:


Author Email:

Author Website:

Comment:

Supported HTML tags for formatting: <strong>bold</strong>   <em>italic</em>   <code>code</code>







  • Help Wanted - Find Your Next ColdFusion Job
InVision App - Prototyping Made Beautiful With Prototyping Tools Ben Nadel's Company - Epicenter Consulting Recent Blog Comments
Feb 12, 2012 at 3:37 AM
Learning ColdFusion 8: CFImage Part III - Watermarks And Transparency
Hi Ben, Just to ask currently it is placed bottom right corner, if i need to replace the same rendered image on the bottom left side or in the bottom center, how that can be calculated. bottom ce ... read »
Feb 11, 2012 at 9:29 PM
Use jQuery's SlideDown() With Fixed-Width Elements To Prevent Jumping
I can't say how glad I am that I found your post. Thank you very much. ... read »
Feb 10, 2012 at 7:21 PM
jQuery AJAX Strips Script Tags And Inserts Them After Parent-Most Elements
Update! Instead of $(eval(options.insertAfter)).after(data['insertData']); I now use: var ajaxNode = document.createElement('span'); var parent = $(eval(options.insertAfter))[0].parentNode; ... read »
Feb 10, 2012 at 6:18 PM
jQuery AJAX Strips Script Tags And Inserts Them After Parent-Most Elements
encountered this same, what I consider, jQuery bug last week. I'm building a site in which I load some content via AJAX. This content contains Linkedin share button placeholders which Linkedin API ne ... read »
Feb 10, 2012 at 11:30 AM
Cross-Origin Resource Sharing (CORS) AJAX Requests Between jQuery And Node.js
After you understand the concepts here, this is an awesome cheatsheet for enabling CORS in just about anything http://enable-cors.org/ ... read »
JM
Feb 10, 2012 at 9:10 AM
My Safari Browser SQLite Database Hello World Example
@Amy, Here is a very good tutorial on how to use JOIN: http://www.sqltutorial.org/sqljoin-innerjoin.aspx ... read »
Feb 10, 2012 at 4:42 AM
Building A Twitter-Inspired RESTful API Architecture In ColdFusion
This is great, very useful Ben. I spotted a small typo in the api.cgm listing: <cfthrow type="Unauthroized" /> Cheers Stefan ... read »
Feb 9, 2012 at 10:35 PM
CFDirectory Filtering Uses Pipe Character For Multiple Filters (Thanks Steve Withington)
I was wondering if there would be a filter you could apply so that you got everything but what you included in the filter. As in show me all docs that are not a .pdf. ... read »