Quantcast
Channel: Adobe Community: Message List - ColdFusion
Viewing all articles
Browse latest Browse all 21760

Coldfusion CFScript Query with MySQL Assignment Operator

$
0
0

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


Viewing all articles
Browse latest Browse all 21760

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>