Support

Search results for ""

Sorry, no results found. Perhaps you would like to search the documentation?
All Topics
John Man

“NOT EXIST” condition with ACP\Query\Bindings

I want to create a query for searching a column (class/column/search.php) that return the posts that do not have a particular meta key. Similar SQL as follow:
SELECT …… WHERE
NOT EXISTS (
SELECT * FROM wp_postmeta AS pm WHERE pm.post_id = p.ID AND pm.meta_key=’meta_value’)

How should I program the binding? Thank you in advance for your guidance.

3 months, 1 week ago
Stefan van den Dungen Gronovius
Developer

Programming custom bindings isn’t well documented, and we don’t use NOT EXISTS queries in any of our bindings. Instead, we support both ‘Is set’ and ‘Is not set’ operators in our plugin. For those cases, an INNER JOIN or LEFT JOIN with a NULL check should achieve a similar result to what you’re aiming for.

If you have a specific operator you want to target with your SQL statement, you can include the entire NOT EXISTS condition directly within the $binding->where() method.

3 months, 1 week ago
John Man

Hi Stefan,

Thank you for replying. I will test out the “is set” and “is not set” operators. The two operations are not listed under “Available operators” in search.php, are the two operations “IS_SET” and “IS_NOT_SET”?

Thank you and have a nice weekend.

3 months, 1 week ago
Stefan van den Dungen Gronovius
Developer

Sorry, those are the labels we have on the front end.
But the keys for the operators as “IS_EMPTY” and “IS_NOT_EMPTY”.
The implementation depends on the column it was made for.

3 months, 1 week ago

You must be logged in to reply to this topic.