Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tpeterw/mysql-query-builder

MySQL query statement builder with natural semantics
https://github.com/tpeterw/mysql-query-builder

java mysql mysql-query-builder natural-semantics

Last synced: 18 days ago
JSON representation

MySQL query statement builder with natural semantics

Awesome Lists containing this project

README

        

# SQL-Query-Builder
SQL query statement builder with natural semantics

Usage
----
### *Just chain everything together*                 ---- Chemistry

String query1 = new SQLQuery()
.select('*')
.from("manuscript")
.where(new SQLCondition()
.whereAttribute("status")
.equalsTo("under review")
.andAttribute("manuscript_id")
.inSubquery(new SQLSubquery()
.select("manuscript_id")
.from("feedback")))
.create();

String query2 = new SQLQuery()
.select("manuscript_id")
.fromSubquery(new SQLSubquery()
.whereTable(new SQLSubquery()
.select("manuscript.manuscript_id", "author_id")
.from("manuscript")
.joinsTable("feedback")
.as('T'))
.joinsTable("issue")
.onAttribute("issue", "period_number"))
.groupBy("author_id")
.orderBy("pub_year", true)
.create();

String query3 = new SQLQuery()
.select('*')
.from("manuscript")
.groupBy("author_id")
.orderBy("author_id", false)
.orderBy("status", true)
.create();

String insert1 = new SQLInsertion()
.intoTable("rihelper")
.intoColumns("reviewer_id", "ricode_id")
.withValues("123456", "111111")
.withValues("234567", "222222")
.create();

String update1 = new SQLUpdate()
.updateTable("author")
.setAttributeTo("email", "[email protected]")
.setAttributeTo("affiliation", 1)
.where(new SQLCondition()
.whereAttribute("author_id")
.equalsTo(123456))
.create();

String delete1 = new SQLDelete()
.fromTable("manuscript")
.where(new SQLCondition()
.whereAttribute("author_id")
.equalsTo("123456"))
.create();

stmt.executeQuery(new SQLQuery()
.select('*')
.from("manuscript")
.create());