SQL 语句规范

一、基本T-SQL 语句

程序中一般使用的基本sql语句

模式

Inset

Insert  into  表名  (列名1,列名2,列名3,...) values   (值1,值2,值3,...)

delete

Delete from where 列名1 = 值1 and 列名2 = 值2 and 列名3 = 值3...

update

Update 表名  set  列名1 = 值1 ,列名2 = 值2 ,列名3 = 值3…   

Select

Select 列名1,列名2,列名3...  from 表名  where 列名1 = 值1 and 列名2 = 值2 and 列名3 = 值3...

示例:以mybatis为例。

tb_Article

id

type_id,user_id,sitemodules_id,status,bigTile,smallTitle,content,source,author,publishTime

and id=#{id}

and type_id=#{typeId}

and user_id=#{userId}

and sitemodules_id=#{sitemodulesId}

and bigTile=#{bigTile}

and smallTitle=#{smallTitle}

and author=#{author}

and publishTime=#{publishTime}

and source=#{source}

and content=#{content}

, type_id=#{typeId}

, user_id=#{userId}

, sitemodules_id=#{sitemodulesId}

, bigTile=#{bigTile}

, smallTitle=#{smallTitle}

, author=#{author}

, publishTime=#{publishTime}

, source=#{source}

, content=#{content}

Insert

  ()

values (#{typeId},#{userId},#{sitemodulesId},#{bigTile},#{smallTitle},#{content},#{source},#{author},#{publishTime})

delete from

where id=#{id}

Update

 

 set id=#{id}

 where id=#{id}

select

,

 from where id=#{id}

select * from

select

,

 from

  where 1=1

select

,

 from

 where 1=1

二、查询的方法

public Integer insertOne(Role role);

根据字段是否为空添加相应的字段

public Integer deleteOneById(String Id);

根据id删除一条记录

public Integer updateOne(Role role);

根据字段是否为空更新相应的字段

public Role selectOneById(String id);

根据id查询一条记录

public List selectListByObj(Role role);

根据对象单表查询出多条记录

public List selectListrefLJByObj(Role role);

根据对象左链接查询出多条记录

public List selectListrefRJByObj(Role role);

根据对象右链接查询出多条记录

public List selectListrefFJByObj(Role role);

根据对象全链接查询出多条记录

public List listPageByObj(Role role);

根据对象单表分页查询出多条记录

public List listPageRefLJByObj(Role role);

根据对象左链接分页查询出多条记录

public List listPageRefRJByObj(Role role);

根据对象右链接分页查询出多条记录

public List listPageRefFJByObj(Role role);

根据对象全链接分页查询出多条记录

评论

h
hw_7864

⭐️ Admin快速开发: https://show.cool-admin.com/

赞 0
h
hw_7864

⭐️ 官方文档: https://cool-js.com

赞 0
h
hw_7864

⭐️ chatgpt在线体验: https://cool-js.com/ai/chat-vip/index.html?r=helloworld

赞 0