0 Replies Latest reply on Jun 20, 2013 12:46 AM by PeteComcar

    Coldfusion CFScript Query with MySQL Assignment Operator

    PeteComcar

      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-assignmen t-operator