本帖最后由 kingfirekkk 于 2010-12-25 23:55 编辑
最近在捣鼓些小东西,要用到MYSQL数据库,基础比较差,使用phpmyadmin能够找出对应的结果,但用Autoit就不知道要怎么搞了。
例如MYSQL源语句如下,问题是:这些查询的结果,怎么处理呢?能否举个例子...
#include <MYSQL.AU3>
Global $MysqlConn = _MySQL_Init()
Global $pass = "root"
Global $connected = _MySQL_Real_Connect($MysqlConn, $SERVER, "root", $pass)
If $connected = 0 Then
$errno = _MySQL_errno($MysqlConn)
MsgBox(0, "Error:", $errno & @LF & _MySQL_error($MysqlConn))
If $errno = $CR_UNKNOWN_HOST Then MsgBox(0, "Error:", "$CR_UNKNOWN_HOST" & @LF & $CR_UNKNOWN_HOST)
_MySQL_Close($MysqlConn)
_MySQL_EndLibrary()
;~ Exit
EndIf
_MySQL_Real_Query($MysqlConn,"SELECT COUNT(*) FROM 表名") ;统计所有数据笔数;
_MySQL_Real_Query($MysqlConn,"SELECT * FROM 表名 WHERE 日期字段 like today%;") ;统计今日目前已经测试数据笔数;
_MySQL_Real_Query($MysqlConn,"select * from test where to_days(Timedate) = to_days(now();"); 查询当天所有数据
_MySQL_Real_Query($MysqlConn,"select * from test where date(Timedate) = curdate();"); 查询当天所有数据:
_MySQL_Real_Query($MysqlConn,"select * from test where DATE_SUB(CURDATE(), INTERVAL 7 DAY) <= date(Timedate);");查询一周:
_MySQL_Real_Query($MysqlConn,"select * from test where DATE_SUB(CURDATE(), INTERVAL INTERVAL 1 MONTH) <= date(Timedate);");;查询一个月:
_MySQL_Real_Query($MysqlConn,"select * from test order by `Timedate` desc limit 5;");最后5行
_MySQL_Real_Query($MysqlConn,"slect * from test order by `Timedate` asc limit 5;"); 最前5行
_MySQL_Real_Query($MysqlConn,"SELECT * FROM test ORDER BY `Timedate` DESC LIMIT 30;"); 最前30行
_MySQL_Real_Query($MysqlConn,"SELECT * FROM `test` WHERE `Timedate` LIKE '2010-12-24%';"); 统计固定日期数据
|