1. 程式人生 > >從javaweb項目學習

從javaweb項目學習

exce 子查詢 -m 上下 .com edate 上下文 否則 util

1.sql語句

在insert語句中需要插入查詢出來的值。 Insert into a (a1,a2,a3) values (1,select num from b where id=1,3) 這樣寫就出現了“在此上下文中不允許使用子查詢。只允許使用標量表達式。”這個錯誤

可以這樣: insert into a (a1,a2,a3) select 1,num,3 from b where id=1 即可解決問題.

2.如何將string類型轉化為sql.date(util.date與sql.date不能直接轉化)

        if (year != null && month != null
&& day != null) { String birthday = year + "-" + month + "-" + day; SimpleDateFormat format = new SimpleDateFormat("yyyy-mm-dd"); java.util.Date d = null; try { d = format.parse(birthday); } catch
(Exception e) { e.printStackTrace(); } java.sql.Date date = new java.sql.Date(d.getTime()); user.setuBirthday(date);

3.除非另外還指定了 TOP 或 FOR XML,否則,ORDER BY 子句在視圖、內聯函數、派生表、子查詢和公用表表達式中無效。

從javaweb項目學習