摘要: 每个Case表达式都是以一个when定义开始的。形式一:获取1980年后加入俱乐部的每个球员的号码、性别、名字。性别必须显示问 ‘Female’或者‘Male’。select playno, case sex when 'F' then 'Female' else 'Male' end as sex, namefrom playerswhere joined > 1980形式二:如果else省略了,并且sex列的值不等于when所定义的标量表达式中的一个的话,将会返回空值。select playno, case sex when ' 阅读全文
posted @ 2011-09-06 00:19 小魏的程序之家 阅读(425) 评论(0) 推荐(1)
摘要: 日期转换为UNIX时间戳用函数UNIX_TIMESTAMP()UNIX时间戳转换为日期用函数: FROM_UNIXTIME()select FROM_UNIXTIME(1156219870);日期转换为UNIX时间戳用函数: UNIX_TIMESTAMP()Select UNIX_TIMESTAMP(’2006-11-04 12:23:00′);例:mysql查询当天的记录数:$sql=”select * from message Where DATE_FORMAT(FROM_UNIXTIME(chattime),’%Y-%m-%d’) = DATE_FORMAT(NOW(),’%Y-%m-% 阅读全文
posted @ 2011-09-05 22:58 小魏的程序之家 阅读(1481) 评论(0) 推荐(0)