Created
November 25, 2016 10:11
-
-
Save ichengzi/275f2beb2caf9d1e87906d159ec35435 to your computer and use it in GitHub Desktop.
mysql数据库
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DROP PROCEDURE IF EXISTS demo; | |
CREATE PROCEDURE demo() | |
BEGIN | |
DECLARE EXIT HANDLER FOR SQLWARNING,NOT FOUND,SQLEXCEPTION | |
BEGIN | |
set @o_ret=-1; | |
SELECT -2; | |
ROLLBACK; | |
END; | |
START TRANSACTION; | |
UPDATE inhospitalrecord | |
set nDirectionsId = 1 | |
WHERE sInHospitalId = 1; | |
/*ROW_COUNT() ==0 不会抛出异常*/ | |
COMMIT; | |
END; | |
call demo(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ORDER BY CAST(`pic_number` AS SIGNED) | |
ORDER BY CAST(`pic_number` AS SIGNED) DESC | |
// output : 1; 2; 2a; 3; 4; 5; 5a; 5b; 5c; 6; 7; 11; 14; 14a; 16; | |
// not : 1; 11; 14; 14a; 16; 2; 2a; 3; 4; 5; 5a; 5b; 5c; 6; 7; | |
// http://dev.mysql.com/doc/refman/5.7/en/cast-functions.html#function_cast | |
// http://www.kreci.net/web-development/sort-varchar-as-int-in-mysql-query/ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment