偷偷摘套内射激情视频,久久精品99国产国产精,中文字幕无线乱码人妻,中文在线中文a,性爽19p

MySQL語句正確插入多值如何運行?

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

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

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

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

 

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

 

 

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

 

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

 

 

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

 

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

 

 

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

 

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

 

 

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

 

 

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

 

 

  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)容就是對MySQL語句插入多值的介紹,望你能有所收獲。

【編輯推薦】

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

2010-05-27 14:47:14

MySQL INSER

2010-05-25 15:24:38

MySQL updat

2010-05-06 09:19:03

Oracle表

2010-05-12 15:00:50

MySQL事件

2010-01-14 15:29:44

C++編譯器

2010-06-09 11:22:06

MySQL datet

2010-05-11 10:12:50

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

2019-11-14 16:23:07

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

2020-04-24 21:41:45

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

2010-05-05 17:53:39

Oracle 8i

2021-04-08 10:55:53

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

2017-08-30 17:47:35

MySql索引

2010-08-19 13:14:17

DB2自動增長主鍵

2010-05-18 15:58:39

MySQL觸發(fā)器

2010-06-01 12:51:23

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

2010-09-08 16:38:13

SQL循環(huán)語句

2010-11-22 16:05:53

MySQL多表插入

2017-11-22 15:33:56

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

2021-07-28 07:22:40

SQL順序Hive

2010-05-17 17:09:29

Mysql LIMIT
點贊
收藏

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