蛋疼sql总结

1 在不能建立索引的情况,保证phone字段的唯一性插入

insert into t_user
          (phone, if_del,create_time)

select * from
          (select '15302755433' as phone ,  0 as ifDel, '2018-04-13 00:00:00' as createTime) as temp
          where not exists

  (select id from t_user where phone = '15302755433' and if_del = 0)

好处:id_del=1情况下,phone就可以重复了


2 @MapKey("tradeType")

map映射

 
 

猜你喜欢

转载自blog.csdn.net/ShuaiFanPi/article/details/79928350