3

我一直在尝试运行此查询以按行号选择一行,但我在 where 子句中不断收到未知列“行”。这个查询可以吗

SELECT @row := @row + 1 AS row, pi.*
FROM ci_patient_info pi
where row = 2
4

2 回答 2

1

把它包在一个subquery

SELECT c.*
FROM
   (
      SELECT @row := @row + 1 AS row, pi.*
      FROM ci_patient_info pi
   ) c
where c.row = 2

更新 1

也许你的子查询应该是这样的,

  SELECT @row := @row + 1 AS row, pi.*
  FROM ci_patient_info pi, (SELECT @row:=0) x
于 2012-10-10T14:25:25.587 回答
1

如果您需要第二条记录,只需使用该LIMIT子句。

SELECT  pi.*
FROM ci_patient_info pi LIMIT 1, 1
于 2012-10-10T14:26:21.303 回答