[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=value2java

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/SqlHandlemysql

相關文章
相關標籤/搜索