Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

SQL Querry that does not exist Phpmyadmin

I am making a sql query to show me the following:

1.- Results that have "_go_product_url" in the meta_key and that is not null.

2.- And I need it to only show me in the results based on the first query that do not have the meta_key "_go_product_info"

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

What would be the best method without spending a lot of resources on the server?
I am working with wordpress. But for now testing in phpmyadmin

I did this query but without results

SELECT * FROM `wp_postmeta`
WHERE `meta_key` LIKE '%_go_product_url%' AND `meta_value` IS NOT NULL AND NOT EXISTS (SELECT * FROM `wp_postmeta` WHERE `meta_key` LIKE '%_go_product_info%' IS NULL);

>Solution :

You presumably want to identify posts meeting these criteria, so you should be selecting something like the post_id and/or the other columns you want. Here is one aggregation approach:

SELECT post_id
FROM wp_postmeta
GROUP BY post_id
HAVING SUM(meta_key LIKE '%_go_product_url%') > 0 AND
       SUM(meta_key LIKE '%_go_product_info%') = 0;
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading