MySQL数据库若何插入多个值_手机内存卡数据怎么
日期:2014-07-13 / 人气: / 来源:网络
以下的文章主要介绍的是MySQL语句正确插入多值的实际操作步骤,以及HQL多表查询及在条件 in 中插入N个变量值的实际操作,我前两天在相关网站看见的资料,觉得挺好,就拿出来供大家分享。
一条sql语句插入多组数据:insert into table values (id,name),(id,name),(id,name) 但似乎语句长度有限制,不能超过1MB,并且该语句是MySQL专用的写法,不是标准sql.
以下转自paradise总结的HQL多表查询的写法及in的使用:
HQL查询多表的时候,取出结果是两个对象的列表,但是我只要我自己想要的属性,之前的HQL语句是这样写的:
from Hytxbz h,Tgbzk t where h.hytxbzid=t.hytxbzid and t.bztgid=:bztgid
结果我debug去看query.list();是Hytxbz和Tgbzk两个对象的列表,结果并不是我想要的,我改成
from Hybztx h where h.hytxbzid in (select t.hytxbzid from Tgbzk where t.bztgid =:bztgid)
还是不行,google一把,发现可以这样写
select h from Hytxbz as h,Tgbzk as t where h.hytxbzid=t.hytxbzid and t.bztgid=:bztgid
如果想取得对应属性的话,也可以这样写
select h.hytxbzid from Hytxbz as h,Tgbzk as t where h.hytxbzid=t.hytxbzid and t.bztgid=:bztgid
发现in的语句可以这样写
String ids[]=new String[]{"1","2","3"};
String hql= " from com,you.YourPOJO where id in (?)";
Query query = session.createQuery(hql);
query .setParameters(ids);
相关方法:
Query setParameters(Object[] objectArray, Type[] typeArray) throws HibernateException;
Query setParameterList(String string, Collection collection, Type type) throws HibernateException;
Query setParameterList(String string, Collection collection) throws HibernateException;
Query setParameterList(String string, Object[] objectArray, Type type) throws HibernateException;
Query setParameterList(String string, Object[] objectArray) throws HibernateException
一条sql语句插入多组数据:insert into table values (id,name),(id,name),(id,name) 但似乎语句长度有限制,不能超过1MB,并且该语句是MySQL专用的写法,不是标准sql.
以下转自paradise总结的HQL多表查询的写法及in的使用:
HQL查询多表的时候,取出结果是两个对象的列表,但是我只要我自己想要的属性,之前的HQL语句是这样写的:
from Hytxbz h,Tgbzk t where h.hytxbzid=t.hytxbzid and t.bztgid=:bztgid
结果我debug去看query.list();是Hytxbz和Tgbzk两个对象的列表,结果并不是我想要的,我改成
from Hybztx h where h.hytxbzid in (select t.hytxbzid from Tgbzk where t.bztgid =:bztgid)
还是不行,google一把,发现可以这样写
select h from Hytxbz as h,Tgbzk as t where h.hytxbzid=t.hytxbzid and t.bztgid=:bztgid
如果想取得对应属性的话,也可以这样写
select h.hytxbzid from Hytxbz as h,Tgbzk as t where h.hytxbzid=t.hytxbzid and t.bztgid=:bztgid
发现in的语句可以这样写
String ids[]=new String[]{"1","2","3"};
String hql= " from com,you.YourPOJO where id in (?)";
Query query = session.createQuery(hql);
query .setParameters(ids);
相关方法:
Query setParameters(Object[] objectArray, Type[] typeArray) throws HibernateException;
Query setParameterList(String string, Collection collection, Type type) throws HibernateException;
Query setParameterList(String string, Collection collection) throws HibernateException;
Query setParameterList(String string, Object[] objectArray, Type type) throws HibernateException;
Query setParameterList(String string, Object[] objectArray) throws HibernateException
使用mydumper多线程快速备份MySQL数据库
Mydumper介绍Mydumper是一个针对MySQL和Drizzle的高性能多线程备份和恢复工具。开发人员主要来自MySQL,Facebook,SkySQL公司。目前已经在一些线上使用了Mydumper。Mydumper主要特性:轻量级C语言写的执行速度比
MySQL,mysql备份命令
作者:管理员
推荐内容 Recommended
- 江苏飞浩信息科技期待您的加入07-20
- 江苏飞浩科技欢迎您07-19
相关内容 Related
- 江苏飞浩信息科技期待您的加入07-20
- 江苏飞浩科技欢迎您07-19