sqlbuilder icon indicating copy to clipboard operation
sqlbuilder copied to clipboard

Missing OR in WHERE

Open Oifan opened this issue 6 years ago • 1 comments

Your library is small and effective, but it only allows logical AND in the WHERE clause. Imagine you need to build a more complex query with several ANDs and ORs -- see these examples: https://www.techonthenet.com/sql/and_or.php . I took a look at your SelectBuilder class and I see for WHERE clause there is only method and(String) -- how can anyone do more complex queries, like this one?:

SELECT * FROM suppliers
WHERE (state = 'California' AND supplier_id <> 900)
OR (supplier_id = 100);

Oifan avatar Jun 18 '18 12:06 Oifan

OR is not missing!

Example: new SelectCreator().column("*").from("suppliers").where(Predicates.or(Predicates.and(Predicates.eq("state", "California"), Predicates.neq("supplier_id", 900)), Predicates.eq("supplier_id", 100)));

s4ibot avatar Jun 18 '18 13:06 s4ibot