我正在尝试从表中获取一些数据。此查询在mysql上运行良好,但在asp.net c#类文件中执行时会引发异常:sql 查询中的致命错误。内部异常 @c 未定义。
string sqlQuery = "SET @c:=0;
SELECT * FROM (SELECT TimeStamp, FwdHr, W , @c:=@c+1 as counter
FROM Meter_Data WHERE TimeStamp >= @fromTime AND TimeStamp <= @toTime
AND MeterID = @meterID" + " AND DeviceID = @deviceID) as tmp
WHERE counter % 20 =1 ORDER BY TimeStamp";
那怎么定义@c
??因为它在SQL Server中运行良好