Ò»¸ö¸´ÔÓµÄ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Ëæ»ú²éѯ¼¸ÌõÊý¾Ý£¬¾ÍÓÃ
SELECT
*
from
`
table
`
ORDER
BY
RAND
() LIMIT
5
¾Í¿ÉÒÔÁË¡£
µ«ÊÇÕæÕý²âÊÔһϲŷ¢ÏÖÕâÑùЧÂʷdz£µÍ¡£Ò»¸ö15ÍòÓàÌõµÄ¿â£¬²éѯ5ÌõÊý¾Ý£¬¾ÓȻҪ8ÃëÒÔÉÏ
²é¿´¹Ù·½ÊֲᣬҲ˵rand()·ÅÔÚORDER BY ×Ó¾äÖлᱻִÐж ......
¸ømysql¿ªÒ»¸ö¿ÉÒÔÔ¶³Ì·ÃÎʵÄÓû§ÃüÁîÈçÏÂ:
GRANT ALL PRIVILEGES ON *.* TO 'myuser'@'%' IDENTIFIED BY 'mypassword' WITH GRANT OPTION;
"*.*" ±íʾÊý¾Ý¿âÖÐËùÓеıí,Ò²¿ÉÒÔ»»³ÉÖ¸¶¨µÄ±íÈçtest.*
"myuser" ±íʾµÄÊÇ·ÃÎʵÄÓû§Ãû;
"%" ±íʾËùÓеÄÖ÷»ú¼´ÈκεÄÖ÷»ú¶¼¿ÉÒÔͨ¹ýÕâ¸öÓû§Ãû·ÃÎÊÎÒµÄÊý¾Ý¿â,Ò²¿ÉÒԸóÉÌض¨µ ......
1. ¸øroot¼ÓÃÜÂ룺/usr/bin/mysqladmin -u root password 123456
2. µ¼³ö£ºmysqldump -u root -p dbname > file.sql
3. µ¼È룺mysql -u root -p dbname < backup-file.sql
4. ÊÚȨ£ºgrant all on *.* to root@"%" identified by "ÃÜÂë";
5. ÊÕ»ØȨÏÞ£ºrevoke all privileges on *.* from root@"%";
6. µÇ¼£ºmys ......
Some problems encounted this afternoon, when trying to setup/test mysql capabilities on hypnos and virgil.
1.ERROR 2003 (HY000): Can't connect to MySQL server on 'server-name' (111)
access locally (i.e. from localhost) is fine, when trying remotely got this error. when tried with mysql++ library, ......