Zum Hauptinhalt springen

IN

in List of Functions
Autorenliste
veröffentlicht: 25. Juni 2019|Letzte Aktualisierung: 3. Nov. 2022

As well as the expressions referenced in our guides  you can use the IN function in DPQL.

The IN operator allows you to specify multiple values in the WHERE clause - essentially it's a shorthand for multiple 'OR' arguments.

A common example of where this might be used is when querying statuses.

You might want to count all the open ticket in your helpdesk.

In Deskpro though open tickets can fall under one of three statuses  - awaiting agent, awaiting user and pending.

Using ORCopy link to Using OR to clipboard

You could run the below:

SELECT DPQL_COUNT() FROM tickets WHERE tickets.status = 'awaiting_agent' OR tickets.status = 'awaiting_user' OR tickets.status = 'pending'
copy

this would output the correct data but is a bit longwinded.

Using INCopy link to Using IN to clipboard

An easier way to do it though is to use the IN operator:

SELECT DPQL_COUNT() FROM tickets WHERE tickets.status IN('awating agent', 'awaiting_user', 'pending')
copy
HilfreichNicht hilfreich
nächste SeiteUsing the LIKE Operator and Wildcards
vorherige SeiteDPQL_PERCENT

Bitte loggen Sie sich ein oder melden Sie sich an, um einen Kommentar zu hinterlassen.