1

This query:

SELECT * FROM getlogs WHERE id > #id# AND logType = "login" LIMIT 1

Gives me this error:

Error Executing Database Query.


Query Of Queries syntax error.
Encountered "logType. Incorrect conditional expression, Incorrect conditional expression, Lexical error at line 0, column 0. Encountered: "\"" (34), after : ""
James A Mohler
  • 11,060
  • 15
  • 46
  • 72
James T
  • 3,292
  • 8
  • 40
  • 70
  • For what database? PostgreSQL, MySQL and SQLite are the only ones I know of that support `LIMIT`, but that doesn't look like it's the issue (or getting that far). Is there a column called "logtype" in the `getlogs` table? – OMG Ponies Mar 02 '11 at 02:26

2 Answers2

8

Use max rows:

< cfquery dbType="query" name"myQ" maxrows="1">
SELECT * FROM getlogs WHERE id > #id# AND logType = "login"
< /cfquery>

CF Guy
  • 96
  • 2
3

Use single quotes instead of double quotes.

Joel Coehoorn
  • 399,467
  • 113
  • 570
  • 794
  • They should add that in the documentation, also, can I use limit? – James T Mar 02 '11 at 02:23
  • @Bubby It is - check the mysql docs. After all, that's the database you're using. It's also part of the ansi-92 sql spec. – Joel Coehoorn Mar 02 '11 at 02:25
  • `Error Executing Database Query. Query Of Queries syntax error. Encountered "LIMIT"` Yeah I'm sure it does >.> – James T Mar 02 '11 at 02:27
  • @Bubby, ah, then you're not using mysql. What database engine are you talking to? – Joel Coehoorn Mar 02 '11 at 02:28
  • The ColdFusion query of queries database, It's a thing that coldfusion has where you can run a SQL statment (I think it's custom to ColdFusion?) on a query object. http://livedocs.adobe.com/coldfusion/8/htmldocs/help.html?content=using_recordsets_7.html#1137985 – James T Mar 02 '11 at 02:32
  • There's no support for "LIMIT" mentioned there anywhere. – Joel Coehoorn Mar 02 '11 at 02:35