Ò»¸ö¸´ÔÓµÄmysql²éѯÓï¾ä(case,when,then,left join )
select `a`.`id` AS `id`,`a`.`UserName` AS `UserName`,
(case when (`a`.`sRegDate` = _utf8'1990-01-01 00:00:00.0') then _utf8'' else cast(date_format(`a`.`sRegDate`,_utf8'%Y-%m-%d %H:%i:%S') as char charset utf8) end) AS `sRegDate`,(case when (`a`.`feeendtime` = _utf8'1990-01-01 00:00:00.0') then _utf8'' else cast(date_format(`a`.`feeendtime`,_utf8'%Y-%m-%d %H:%i:%S') as char charset utf8) end) AS `feeendtime`,
(case when (`a`.`iStatus` = _utf8'0') then _utf8'Õý³£' when (`a`.`iStatus` = _utf8'1') then _utf8'Ëø¶¨' when (`a`.`iStatus` = _utf8'2') then _utf8'Ç··Ñ' when (`a`.`iStatus` = _utf8'') then _utf8'ÉêÇëÍ£»ú' else _utf8'' end) AS `iStatus`,
(case when (`a`.`PayType` = _utf8'0') then _utf8'Ãâ·Ñ' when (`a`.`PayType` = _utf8'2') then _utf8'Ð¡ÇøÍøÓû§' when (`a`.`PayType` = _utf8'10') then _utf8'ÍⲿÓû§' else _utf8'' end) AS `PayType`,
`c`.`UserType` AS `sDh1`,`b`.`FeeName` AS `iFeeType`,
(case when (`a`.`PauseStartTime` = _utf8'1990-01-01 00:00:00.0') then _utf8'' else cast(date_format(`a`.`PauseStartTime`,_utf8'%Y-%m-%d %H:%i:%S') as char charset utf8) end) AS `PauseStartTime`,
(case when (`a`.`PauseStopTime` = _utf8'1990-01-01 00:00:00.0') then _utf8'' else cast(date_format(`a`.`PauseStopTime`,_utf8'%Y-%m-%d %H:%i:%S') as char charset utf8) end) AS `PauseStopTime`,
(case when (`a`.`AcctStartTime` = _utf8'1990-01-01 00:00:00.0') then _utf8'' else cast(date_format(`a`.`AcctStartTime`,_utf8'%Y-%m-%d %H:%i:%S') as char charset utf8) end) AS `AcctStartTime`,
(case when (`a`.`AcctStopTime` = _utf8'1990-01-01 00:00:00.0') then _utf8'' else cast(date_format(`a`.`AcctStopTime`,_utf8'%Y-%m-%d %H:%i:%S') as char charset utf8) end) AS `AcctStopTime`,
`a`.`speed` AS `speed`,
(case when (`a`.`idtype` = _utf8'7') then _utf8'Éí·ÝÖ¤' when (`a`.`idtype` = _utf8'1') then _utf8'½ÌÖ°¹¤' when (`a`.`idtype` = _utf8'2') then _utf8'±¾¿ÆÉú' when (`a`.`idtype` = _utf8'3') then _utf8'Ñо¿Éú' when (`a`.`idtype` = _utf8'4') then _utf8'ÀëÍËÉú' when (`a`.`idtype` = _utf8'5') then _utf8'
Ïà¹ØÎĵµ£º
mysqlµÄ find_in_setº¯ÊýʹÓ÷½·¨
ºÜ¶àʱºòÎÒÃÇÔÚÉè¼ÆÊý¾Ý¿âʱÓÐÕâÖÖÇé¿ö,±ÈÈç:
ÓиöÎÄÕ±íÀïÃæÓиötype×Ö¶Î,Ëû´æ´¢µÄÊÇÎÄÕÂÀàÐÍ,ÓÐ 1Í·Ìõ,2ÍÆ¼ö,3Èȵã,4ͼÎÄ .....11,12,13µÈµÈ
ÏÖÔÚÓÐÆªÎÄÕÂËû¼ÈÊÇ Í·Ìõ,ÓÖÊÇÈȵã,»¹ÊÇͼÎÄ,
typeÖÐÒÔ 1,3,4µÄ¸ñʽ´æ´¢.
ÄÇÃÇÎÒÃÇÈçºÎÓÃsql²éÕÒËùÓÐtypeÖÐÓÐ4ͼÎıê×¼µÄÎÄÕÂÄØ ......
1£º Can’t connect to [local] MySQL server´íÎó
Ò»¸öMySQL¿Í»§¿ÉÒÔÁ½ÖÖ²»Í¬µÄ·½Ê½Á¬½Ómysqld·þÎñÆ÷£ºUnixÌ×½Ó×Ö£¬Ëüͨ¹ýÔÚÎļþϵͳÖеÄÒ»¸öÎļþ(ȱʡ“/tmp /mysqld.sock”)½øÐÐÁ¬½Ó£»»òTCP/IP£¬Ëüͨ¹ýÒ»¸ö¶Ë¿ÚºÅÁ¬½Ó¡£UnixÌ×½Ó×Ö±ÈTCP/IP¸ü¿ì£¬µ«ÊÇÖ»ÓÐÓÃÔÚÁ¬½Óͬһ̨¼ÆËã»úÉϵķþÎñÆ÷¡£Èç¹ûÄ ......
×òÌìÓиö¹¦ÄÜҪʵÏÖÅÅÐÐЧ¹û£¬¶øÇÒÊÇËæ»ú°´ÕÕijЩ×ֶεÄ×ÜÖµ£¬µ«ÊǵÚÒ»¸öÓÖÒª²»Ò»Ñù£¬ÒòΪµÚÒ»¸öÈ˸øÁËÇ®£¬ËùÒÔÒªÅŵÚÒ»¡£
´ò¸ö±È·½°É£¬±í(userinfo)ÖÐÓÐÕ⼸¸ö×ֶΣºusername,isvalid,givedmoney,sumip,dayip,monthip,visitcount,regdate
ÏÖÔÚҪʵÏÖÏÔʾÅÅÐÐǰ10λÓû§£¬
³öÏÖÔÚÅÅÐеÚһλµ ......
ÓÃmysql_query£¬mysql_fetch_array()ºóÓ¦¸ÃÒª
free_result().function count_admin($where = '')
{
if($where) $where = " WHERE $where";
$result = $this->db->get_one("SELECT count(*) as num from $this->table_admin_role $where");
return $result['num'];
} ......
°²×°ÅäÖÃmysql
http://edu.codepub.com/2009/1213/18710.php
Ò»¡¢
ÏÂÔØ±àÒë°²×°
#cd /usr/local/src/
#wget http://mysql.byungsoo.net/Downloads/MySQL-5.1/mysql-5.1.38.tar.gz
#tar –xzvf mysql-5.1.38.tar.gz ../software/
#./configure
--prefix=/usr/local/mysql //MySQL°²×°Ä¿Â¼
--datadir=/mydata / ......