SELECT card_id,CAST(SUBSTRING(card_id,7,8) AS DATETIME) AS bir,FROM_UNIXTIME(UNIX_TIMESTAMP(CAST(SUBSTRING(card_id,7,8) AS DATETIME)),'%m-%d') AS TIME,IF(LEFT(SUBSTRING(card_id,17),1)%2=1,"男","女") AS sex FROM card
sql语句
.....
sql语句
DROP TABLE IF EXISTS `card`;
CREATE TABLE `card` (
`id` int(14) NOT NULL AUTO_INCREMENT,
`card_id` varchar(18) DEFAULT NULL,
`name` varchar(20) DEFAULT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8;
/*Data for the table `card` */
insert into `card`(`id`,`card_id`,`name`) values (1,'52040219770325X064','李四');
转载请注明:谷谷点程序 » mysql获取身份证号的生日姓别