我一直在尝试运行此查询以按行号选择一行,但我在 where 子句中不断收到未知列“行”。这个查询可以吗
SELECT @row := @row + 1 AS row, pi.*
FROM ci_patient_info pi
where row = 2
我一直在尝试运行此查询以按行号选择一行,但我在 where 子句中不断收到未知列“行”。这个查询可以吗
SELECT @row := @row + 1 AS row, pi.*
FROM ci_patient_info pi
where row = 2
把它包在一个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
如果您需要第二条记录,只需使用该LIMIT
子句。
SELECT pi.*
FROM ci_patient_info pi LIMIT 1, 1