jQuery-QueryBuilder icon indicating copy to clipboard operation
jQuery-QueryBuilder copied to clipboard

SELECT/ORDER/JOINS with jQuery Query Builder?

Open IS0metric opened this issue 8 years ago • 5 comments

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!

IS0metric avatar Jun 27 '16 13:06 IS0metric

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"

mistic100 avatar Jun 27 '16 16:06 mistic100

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?

rjendoubi avatar Jul 08 '17 13:07 rjendoubi

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"}]}]}

mannava avatar Jun 24 '18 03:06 mannava

I was searching through your issues, any chance we could get a SUM or Count on a col

papyr avatar Nov 10 '18 20:11 papyr

@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.

mistic100 avatar Nov 10 '18 21:11 mistic100