带有where子句问题的mysql行号

时间:2015-03-24 12:44:04

标签: mysql

我有以下查询,我在哪里计算行号:

 SELECT @rank := @rank + 1 AS rnkk, tdate, billno, party_name, net_total, pid FROM purchase_bill_wise  , (SELECT @rank := 0) rnk;

完美地返回行号。当我在查询中放置where子句时会出现问题,如下所示:

SELECT @rank := @rank + 1 AS rnkk, tdate, billno, party_name, net_total, pid FROM purchase_bill_wise WHERE tdate = '2013-09-18' ,  (SELECT @rank := 0) rnk;

我收到错误代码:1064

1 个答案:

答案 0 :(得分:1)

交叉联接应该在select ... from table_name

之后
SELECT 
 @rank := @rank + 1 AS rnkk, 
 tdate, 
 billno, 
 party_name, 
 net_total, 
 pid 
 FROM purchase_bill_wise,(SELECT @rank := 0) rnk
 WHERE tdate = '2013-09-18'
 ;