自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

MySQL語(yǔ)句正確插入多值如何運(yùn)行?

數(shù)據(jù)庫(kù) MySQL
我們今天主要向大家描述的是MySQL語(yǔ)句正確插入多值的實(shí)際操作步驟,如果你對(duì)MySQL語(yǔ)句正確插入多值的實(shí)際操作步驟感興趣的話,你不妨瀏覽以下的文章。

以下的文章主要介紹的是MySQL語(yǔ)句正確插入多值的實(shí)際操作步驟,以及HQL多表查詢及在條件 in 中插入N個(gè)變量值的實(shí)際操作,我前兩天在相關(guān)網(wǎng)站看見(jiàn)的資料,覺(jué)得挺好,就拿出來(lái)供大家分享。

一條sql語(yǔ)句插入多組數(shù)據(jù):insert into table values (id,name),(id,name),(id,name) 但似乎語(yǔ)句長(zhǎng)度有限制,不能超過(guò)1MB,并且該語(yǔ)句是MySQL專用的寫(xiě)法,不是標(biāo)準(zhǔn)sql.

以下轉(zhuǎn)自paradise總結(jié)的HQL多表查詢的寫(xiě)法及in的使用:

 

HQL查詢多表的時(shí)候,取出結(jié)果是兩個(gè)對(duì)象的列表,但是我只要我自己想要的屬性,之前的HQL語(yǔ)句是這樣寫(xiě)的:

 

 

  1. from Hytxbz h,Tgbzk t where h.hytxbzid=t.hytxbzid and t.bztgid=:bztgid 

 

結(jié)果我debug去看query.list();是Hytxbz和Tgbzk兩個(gè)對(duì)象的列表,結(jié)果并不是我想要的,我改成

 

 

  1. from Hybztx h where h.hytxbzid in (select t.hytxbzid from Tgbzk where t.bztgid =:bztgid) 

 

還是不行,google一把,發(fā)現(xiàn)可以這樣寫(xiě)

 

 

  1. select h from Hytxbz as h,Tgbzk as t where h.hytxbzid=t.hytxbzid and t.bztgid=:bztgid 

 

如果想取得對(duì)應(yīng)屬性的話,也可以這樣寫(xiě)

 

 

  1. select h.hytxbzid from Hytxbz as h,Tgbzk as t where h.hytxbzid=t.hytxbzid and t.bztgid=:bztgid 

 

 

發(fā)現(xiàn)in的語(yǔ)句可以這樣寫(xiě)

 

 

  1. String ids[]=new String[]{"1","2","3"};   
  2. String hql" from com,you.YourPOJO where id in (?)";   
  3. Query query = session.createQuery(hql);   
  4. query .setParameters(ids); 

 

 

相關(guān)方法:

 

 

  1. Query setParameters(Object[] objectArray, Type[] typeArray) throws HibernateException;   
  2. Query setParameterList(String string, Collection collection, Type type) throws HibernateException;   
  3. Query setParameterList(String string, Collection collection) throws HibernateException;   
  4. Query setParameterList(String string, Object[] objectArray, Type type) throws HibernateException;   
  5. Query setParameterList(String string, Object[] objectArray) throws HibernateException 

 

 

 以上的相關(guān)內(nèi)容就是對(duì)MySQL語(yǔ)句插入多值的介紹,望你能有所收獲。

【編輯推薦】

  1. MySQL臨時(shí)表的具體使用方案
  2. 用Excel如何對(duì)MySQL數(shù)據(jù)進(jìn)行分析
  3. MySQL數(shù)據(jù)類型與相應(yīng)的建庫(kù)策略
  4. MySQL數(shù)據(jù)庫(kù)中定義外鍵的必備條件
  5. MySQL數(shù)據(jù)庫(kù)所支持的三個(gè)引擎
責(zé)任編輯:佚名 來(lái)源: 互聯(lián)網(wǎng)
相關(guān)推薦

2010-05-25 15:24:38

MySQL updat

2010-05-27 14:47:14

MySQL INSER

2010-05-06 09:19:03

Oracle表

2010-05-12 15:00:50

MySQL事件

2010-06-09 11:22:06

MySQL datet

2010-05-11 10:12:50

mysql數(shù)據(jù)庫(kù)sql

2010-01-14 15:29:44

C++編譯器

2020-04-24 21:41:45

MySQL數(shù)據(jù)庫(kù)插入數(shù)據(jù)

2021-04-08 10:55:53

MySQL數(shù)據(jù)庫(kù)代碼

2019-11-14 16:23:07

MySQL索引數(shù)據(jù)庫(kù)

2010-05-05 17:53:39

Oracle 8i

2017-08-30 17:47:35

MySql索引

2010-08-19 13:14:17

DB2自動(dòng)增長(zhǎng)主鍵

2010-06-01 12:51:23

MySQL數(shù)據(jù)庫(kù)

2010-05-18 15:58:39

MySQL觸發(fā)器

2010-09-08 16:38:13

SQL循環(huán)語(yǔ)句

2010-11-22 16:05:53

MySQL多表插入

2017-11-22 15:33:56

MySQL快速插入語(yǔ)句優(yōu)化

2011-08-16 09:21:30

MySQL大數(shù)據(jù)量快速語(yǔ)句優(yōu)化

2021-07-28 07:22:40

SQL順序Hive
點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)