1.關聯修改
#解決思路 UPDATE tb1,tb2 SET tb1.address=tb2.address WHERE tb1.name=tb2.name UPDATE car c,tmpcolorcode t SET c.color_code=t.color_code WHERE c.reg_no=t.reg_no;
2.long與datetime類型相互轉換
#時間datetime轉換為long格式 SELECT UNIX_TIMESTAMP(NOW()); #1410403824 #時間long轉換為datetime格式 SELECT FROM_UNIXTIME(1410403824); #2014-09-11 10:50:24
3.在實際的處理過程中,需要除以1000
SELECT id,mobile,CODE,FROM_UNIXTIME(create_time/1000) AS createTime,TYPE FROM `mobile_code` ORDER BY id DESC;
4.Java代碼:
public static void main(String[] args) { Date d = new Date(); System.out.println("long型數據: " + d.getTime()); System.out.println("sys型數據: " + System.currentTimeMillis()); } long型數據: 1410404639799 sys型數據: 1410404639799 SELECT FROM_UNIXTIME(1410404639799/1000);