• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Coldfusion CFScript Query with MySQL Assignment Operator

Participant ,
Jun 20, 2013 Jun 20, 2013

Copy link to clipboard

Copied

I want to select "currentrow" as part of my query - I know I can loop over queries and get the "currentRow" variable, but I'm doing a QoQ before I use the rows and I want to keep the original rows, e.g.

//Original query

1, Audi

2, BMW

3, Skoda

//QoQ

1, Audi

3, Skoda

This is the code I've got:

q = new Query( datasource = application.db.comcar );

q.setSQL(' SELECT make, @rownum := @rownum +1 AS  `rownumber` FROM cars, ( SELECT @rownum :=0 ) LIMIT 10 ');

r = q.execute().getResult();

But it's throwing the following error:

Parameter '=' not found in the list of parameters specified 

SQL: SELECT make, @rownum := @rownum + 1 AS `rownumber` FROM cars, ( SELECT @rownum    :=0 ) LIMIT 10

This will work in "cfquery" but I'd like to use it in CFScript. Is there an alternative to using ":=" or some way of escaping this in the query.

- Originally posted on Stack Overlfow: http://stackoverflow.com/questions/17191530/coldfusion-cfscript-query-with-mysql-assignment-operator

Views

721

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
no replies

Have something to add?

Join the conversation
Resources
Documentation