sql语句

本文介绍了使用SQL进行数据更新及多种查询操作的方法,包括条件更新、模糊查询、联表查询等,并提供了具体示例。此外,还涉及了权限授予、分页查询等内容。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

 //更新

   @Transactional

   @Modifying

   @Query(value = "UPDATE dic SET name =?1, type = ?2, code = ?3, comment = ?4, create_time = ?5 WHERE id = ?6" , nativeQuery = true)

   public int upDataManager(String name, String type, String code, String comment, String time,Integer managerId);

saveandflush


sql添加一个用户

GRANT all on test.* to test@"%" IDENTIFIED by "123456";

flush PRIVILEGES


查询两张表

SELECT

info.id ,

info.app_id ,

info.token ,

info.encoding_aes_key ,

info.create_time ,

info.original_id ,

d.`name` AS 'wx_type'

FROM

public_users_info AS info ,

dic AS d

WHERE

info.type = d. CODE

AND d.type = 'wx_type'

AND d. CODE = 1


模糊查询

  1. SELECT * from  public_users_info  a left join  public_users b on a.public_user_id=b.id left join  dic c  on a.type=c.`code` 

  where   (a.id like '%1%' or a.`name` LIKE '%1%' or a.app_id like '%1%' or a.app_secret like '%1%') ORDER  BY a.id 


  1. SELECT * from  public_users_info  a left join  public_users b on a.public_user_id=b.id

  where   (a.id like '%1%' or a.`name` LIKE '%1%' or a.app_id like '%1%' or a.app_secret like '%1%') ORDER  BY a.id 


  1. SELECT * from  public_users_info  a  where   (a.id like '%1%' or a.`name` LIKE '%1%' or a.app_id like '%1%' or a.app_secret like '%1%') ORDER  BY a.id 

坑:sql语句中的《*》很耗时,尽量不用



//分页查询

select *from table limit size*page, size

或者用pageable

分页查询


分页详情点击打开链接

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值