关于php获取mysql的指定记录

henhencai 2009-10-14 07:15:00
如上
php如果获取mysql表记录的指定信息呀?
比如想要获取表table的pw_num字段的记录分别为0,11,8,3,9
怎么才能获得字段pw_num里面大于5的值呀?(11,8,9)

请高手帮忙解决一下
谢谢
...全文
124 7 打赏 收藏 转发到动态 举报
写回复
用AI写文章
7 条回复
切换为时间正序
请发表友善的回复…
发表回复
henhencai 2009-10-15
  • 打赏
  • 举报
回复
+----------+---------------------+------+
| 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 |
+----------+---------------------+------+


fengyqf 2009-10-14
  • 打赏
  • 举报
回复
楼主是找这个的函数吧?
group_concat(pw_num)
三楼正解
wjy217213 2009-10-14
  • 打赏
  • 举报
回复
[Quote=引用 3 楼 zhoupuyue 的回复:]
如果想作为一条记录返回:
SQL code
mysql>select*from t;+------+--------+| id| pw_num|+------+--------+|1|0||2|11||3|8||4|3|+------+--------+4 rowsinset (0.00 sec)

mysql>select group_concat(pw_num)from twhere pw_num>5;+----------------------+| group_concat(pw_num)|+----------------------+|11,8|+----------------------+1 rowinset (0.00 sec)
[/Quote]

yusmartboy 2009-10-14
  • 打赏
  • 举报
回复
关于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];
}
阿_布 2009-10-14
  • 打赏
  • 举报
回复
如果想作为一条记录返回:

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)
jackydrl 2009-10-14
  • 打赏
  • 举报
回复
???

select * from table where pw_num>5
阿_布 2009-10-14
  • 打赏
  • 举报
回复

select * from table where pw_num>5;

不太明白lz的意思。

21,891

社区成员

发帖
与我相关
我的任务
社区描述
从PHP安装配置,PHP入门,PHP基础到PHP应用
社区管理员
  • 基础编程社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧