How to use the same column several times in the place where the hash in Qore SqlUtil

How to use column several times in volume hash in Qore SqlUtil?

SQL example: colname in (...) and colname not in (...)

Here where the hash will look like this:

 hash sh = ('where': ( 'colname': op_in(...), 'colname': op_not(op_in(...)), )); 

Of course, the same key cannot be used more than once in a hash.

+5
source share
1 answer

This is possible - see: https://docs.qore.org/current/modules/SqlUtil/html/sql_operations.html#where_clauses

from documents:

To refer to a column more than once in a where clause, a column specification prefix with a unique number and a colon, as in the following example:

 hash w = ("0:created": op_ge(mindate), "1:created": op_lt(maxdate)); 

the numerical prefix, as in the above example (together with a colon), is deleted when the query is generated and is used only to display the same column name more than once in the generated query.

Your example might look like this:

 hash sh = ( "where": ( "0:colname": op_in(...), "1:colname": op_not(op_in(...)), ), ); 
+6
source

Source: https://habr.com/ru/post/1267172/


All Articles