如果想作为一条记录返回:mysql> select * from t; +------+--------+ | id | pw_num | +------+--------+ | 1 | 0 | | 2 | 11 | | 3 | 8 | | 4 | 3 | +------+--------+ 4 rows in set (0.00 sec)mysql> select group_concat(pw_num) from t where pw_num>5; +----------------------+ | group_concat(pw_num) | +----------------------+ | 11,8 | +----------------------+ 1 row in set (0.00 sec)
关于php应用,对于mysql数据库,语句为: $sql=mysql_query("select pw_num from tablename order by pw_num desc",$conn); //$conn是数据库连接 while($info=mysql_fetch_array($sql)) { echo $info[pw_num]; }
select * from table where pw_num>5;不太明白lz的意思。
+------+--------+
| id | pw_num |
+------+--------+
| 1 | 0 |
| 2 | 11 |
| 3 | 8 |
| 4 | 3 |
+------+--------+
4 rows in set (0.00 sec)mysql> select group_concat(pw_num) from t where pw_num>5;
+----------------------+
| group_concat(pw_num) |
+----------------------+
| 11,8 |
+----------------------+
1 row in set (0.00 sec)
$sql=mysql_query("select pw_num from tablename order by pw_num desc",$conn);
//$conn是数据库连接
while($info=mysql_fetch_array($sql))
{
echo $info[pw_num];
}
group_concat(pw_num)
三楼正解
| username | usertime | type |
+----------+---------------------+------+
| | 2009-10-15 09:48:12 | 0 |
| 456 | 2009-10-14 20:30:07 | 1 |
| 789 | 2009-10-14 20:30:32 | 2 |
| 99 | 2009-10-15 10:36:55 | 1 |
| 333 | 2009-10-15 10:39:38 | 1 |
| 888 | 2009-10-15 10:34:11 | 0 |
+----------+---------------------+------+