[SqlHandle] java mysql语法 sql语句拼接工具简类

SqlHandle sqlhandle =new SqlHandle(SqlHandle.OPERATES[2],table);
sqlhandle.OPERATEFILED(field1, value1);

# SqlHandle
 * mysql语法 sql语句拼接工具简类
 * 使用场景:需要快速书写sql语句时用到,主要使用的是mysql中的sql语法
 * 该版本的select语句只支持单表查询,不支持多表查询,待更新
 * where 语句中关联多个字段默认使用And关键字,暂不可更改,待更新
常量说明:
	/**
	 * 排序操作符:顺序 "ASC","DESC"
	 */
	public static final String[] SORTS ={"ASC","DESC"};
	/**
	 * 数据库操作符:顺序 "select","insert","update","delete"
	 */
	public static final String[] OPERATES={"select","insert","update","delete"};


#使用示例:
生成 select * from user
//默认使用select语句
SqlHandle sqlhandle =new SqlHandle("user");


生成查询 select field1 as f1,field2 as f2 from user where field1=value order by field1 ASC limit 0,5
SqlHandle sqlhandle =new SqlHandle("user");
sqlhandle.FIELD(field,alias).CONDITION(filed1,"=", value).ORDERBY(SqlHandle.SORTS[0], field1).LIMIT(0,5);



生成插入 insert table SET field1=value1,field2=value2

SqlHandle sqlhandle =new SqlHandle(SqlHandle.OPERATES[1],table);
sqlhandle.OPERATEFILED(field1, value1).OPERATEFILED(field2, value2);



生成插入 insert table values(value1,value2)

SqlHandle sqlhandle =new SqlHandle(SqlHandle.OPERATES[1],table);
sqlhandle.OPERATEFILED(value1).OPERATEFILED(value2)


生成更新 update table set field1=value1 where field1=value1

SqlHandle sqlhandle =new SqlHandle(SqlHandle.OPERATES[2],table);
sqlhandle.OPERATEFILED(field1, value1);


生成删除 delete from table where field1=value1
SqlHandle sqlhandle =new SqlHandle(SqlHandle.OPERATES[3],table);
sqlhandle.OPERATEFILED(field1, value1);


项目git分享地址:https://github.com/yoqu/SqlHandle


评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值