我需要在mysql中使用php获取特定行的特定列值。
例如,如果我想获取row2中的column2值,则尝试使用:
$qry = mysql_query("SELECT * from $table");
$data = mysql_fetch_row($qry);
$result = $data[1];
但这总是只返回第一行值。
最佳答案
SELECT Column2
FROM $table
ORDER BY Something
LIMIT 1,1;
或者,如果您知道该行的键
SELECT Column2
FROM $table
WHERE Key = Something
-- Optional: if you want 2nd after filtering
-- ORDER BY Something
-- LIMIT 1,1;
关于php - MySQL获取特定行的列值,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/7380161/