数据库
java_陈序猿
工作总结积累
展开
-
获取 刚才插入行的 id
jdbc: pmGetPrizeID = orcDbConn.prepareStatement("select SEQ_GET_PRIZE_ID.currval as id from dual"); msGetPrizeId = pmGetPrizeID.executeQuery();JFinal: Record getP原创 2016-07-05 13:42:32 · 381 阅读 · 0 评论 -
oracl 自增长序列 和触发器
自增序列:create sequence RSminvalue 10 最小值nomaxvalue 无最大值start with 20 开始值increment by 1 每次加1nocycle 不循环 nocache; 不进缓存触发器:CREATE OR REPLACE TRIGGER RstBEFOR原创 2016-07-05 13:44:21 · 336 阅读 · 0 评论 -
ibatis 模糊查询和多条件查询
<select id="getList" parameterType="remotecollaborationDO" resultType="remotecollaborationDO" > SELECT t1.id,t1.send_user_id,t1.status,t1.content,t1.profile, t原创 2016-07-05 13:45:55 · 748 阅读 · 0 评论 -
mysql数据库迁移
前言:工作中需要把一个数据库的表结构和数据迁移到另一个数据库中。现有环境:日语版的HeidiSQL第一步:把数据库的数据导出来在你想要导出的数据库上单击右键,如下图:原创 2016-07-06 16:52:42 · 470 阅读 · 0 评论 -
mysql 连续签到7天 查询
select * from (select p.id pid,p.name,p.create_time,u.id,u.mobile,u.realname,u.authname,u.register_time,u.register_ip from project p inner join user u on p.user_id = u.id and p.id in ( Select DIS原创 2016-08-16 17:27:54 · 5419 阅读 · 0 评论 -
mybatis in集合使用和小于大于转义
void changeGroups(@Param("ids") List<Long> groupIds);in<foreach item="tagName" index="index" collection="ids" open="(" separator="," close=")"> #{tagName}</foreach...原创 2017-02-16 11:12:32 · 1412 阅读 · 0 评论 -
linux 安装mysql和主从配置 + Spring 基于注解配置mysql读写分离
1. 卸载已有的mysqlhttp://www.cnblogs.com/kerrycode/p/4364465.html1.安装mysqlyum -y install wget下载 http://dev.mysql.com/get/mysql57-community-release-el7-11.noarch.rpm 或者https://download.csdn.net/down...原创 2019-12-18 09:06:32 · 380 阅读 · 1 评论 -
时间格式 前台转换和 sql处理
一 . controller <span style="white-space:pre"> </span> String 传成 Timestamp SimpleDateFormat SDF_1 = new SimpleDateFormat("yyyy/MM/dd HH:mm"); Date pubTime = S...原创 2016-07-05 13:40:02 · 862 阅读 · 0 评论 -
mysql IFNUll+leftpad
IFNULL( tb.lookback_time,0) as lookback_timeIFNULL(u.nick,concat('userName[',LPAD(u.id,11,0),']')) nick,CONVERT(ifnull(sum(gp.price),0), SIGNED)原创 2016-07-05 13:35:47 · 422 阅读 · 0 评论 -
数据类型转换 text 转 double 再保留两位小数
round(rp.num/cast(si.value as DECIMAL),2) as pricejava 后台数据 double 保留两位小数:BigDecimal bd = new BigDecimal(bj.getInt("resid_tael") / Double.parseDouble(sys.getStr("value"))); double rmb = bd.原创 2016-07-05 13:34:31 · 1439 阅读 · 0 评论 -
mysql case
查看粉丝 及是否关注该粉丝select f.*, case when f1.id is null then '1' else '0' endf_state from follow f left join follow f1 on f1.follow_from = f.follow_to and f1.follow_to = f.follow_from and f1.state = '0'原创 2016-07-05 13:33:35 · 342 阅读 · 0 评论 -
模糊查询
and (l.title like concat('%',?,'%') or b.name like concat('%',?,'%'))原创 2016-07-05 13:32:52 · 360 阅读 · 0 评论 -
mysql group by 获取max(id) 的行数据 和 mybatis foreach 标签的使用
默认mysql group by 获得行数据是id最小,一般情况下需求是获取id最大的行数据,可以使用max(id) inner join 的方式获取goupby id 最大的行数据例子:select max(tt.id) as id from zdprogress as tt where tt.zid in (146,148,149) group by tt.zid ) as t1 ...原创 2019-02-15 16:50:17 · 2996 阅读 · 0 评论