因此,假设这是MySQL中数据库的层次结构。
Database: Example
Table: Test
Row 1
Column 1 ("one"): Whatever
Column 2 ("two"): Something
Column 3 ("three"): Test
Row 2
Column 1 ("one"): Blah
Column 2 ("two"): Testing
Column 3 ("three"): Yup
如何返回值为one
列的数组?
数组看起来像这样:
Array ( [0] => Whatever [1] => Blah )
答案 0 :(得分:3)
我认为很简单。
select Column 1 From tablename;
答案 1 :(得分:1)
可能与空间有关。如果列名中有空格,请使用引号,例如
select `Column 1` from tablename;
我不确定你的例子是否描述了你的实际问题:(
答案 2 :(得分:1)
$query = "SELECT column1 FROM test";
$result = mysql_query($query);
$numRows = mysql_num_rows($result); // should be 2
while($row = mysql_fetch_array($result)) {
$row[0]; // data from column
}