我一直在尝试运行此查询以按行号选择行,但我一直在where子句中获取未知列'row'。这个查询是否可能
SELECT @row := @row + 1 AS row, pi.*
FROM ci_patient_info pi
where row = 2
答案 0 :(得分: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
答案 1 :(得分:1)
如果您需要第二条记录,只需使用LIMIT
条款。
SELECT pi.*
FROM ci_patient_info pi LIMIT 1, 1