mistic100 / jQuery-QueryBuilder

jQuery plugin offering an interface to create complex queries
https://querybuilder.js.org
MIT License
1.68k stars 552 forks source link

SELECT/ORDER/JOINS with jQuery Query Builder? #310

Open IS0metric opened 8 years ago

IS0metric commented 8 years ago

Hello all,

Firstly, thank you very much for your hard work on this project - it has been very useful to me.

I have an issue though - when using SQL, how would one specify SELECT statements? Here's the example I'm trying to achieve:

SELECT city, airport
FROM mytable
WHERE owner = "admin"
AND (
    city = "Venice"
    OR city = "Palma"
);

My database table is, very simply, as follows:

+--------------------------------------+
| city       | owner      | airport    |
+--------------------------------------+
| ...        | ...        | ...        |
|            |            |            |
+--------------------------------------+

The query builder handles the WHERE part very well, but could it be used to express SELECTs as well? And building upon that, what about COUNT() and GROUP BY, or ORDER BY and LIMIT? Is that something that I could start doing with the query builder or would I have to write it all myself?

Thanks!

mistic100 commented 8 years ago

My point of view and time didn't change from #114.

I leave this open though because I can't deny it's a common request but I mark as "won't fix", meaning "perhaps, perhaps not, don't expect anything"

rjendoubi commented 7 years ago

I've read up on #114 and take the point re SELECTs. Is there a similar alternative you'd recommend for JOINs? Or should JOINs be represented with e.g. field type = integer and input = select, with the logic to handle those integer values as FKs implemented in the backend?

mannava commented 6 years ago

I am struggling to generate sql query using JSON. could you please tell me the right library for that. I was trying with "json-rules-engine-simplified"

The following json generated by JqueryQueryBuilder. I need auto generated sql query for the following kind JSON. Could you please help me ASAP.

let rule = {"condition":"and","rules":[{"field":"TRXN_ID","operator":"=","value":"987654"},{"field":"SALESDOCNUM","operator":"=","value":"9876543"},{"field":"DCNUMBER","operator":"=","value":"87654"},{"condition":"or","rules":[{"field":"ORD_ID","operator":"=","value":"2345"}]}]}

papyr commented 5 years ago

I was searching through your issues, any chance we could get a SUMor Counton a col

mistic100 commented 5 years ago

@papyr this is not the subject of this issue

you can find here a similar issue about using custom SQL functions https://github.com/mistic100/jQuery-QueryBuilder/issues/334 (check my final comment with the unit test)

do not answer here if you need more help, create a new issue.