Skip to content
Advertisement

SQL query with meta_key,meta_value and have 2 conditions

I am trying to do an SQL query to find a form id of the Registration form of the user on a wordpress site, because this form doesn’t have the id of the user yet, I have to find the user email which is unique and check if the gdprchekbox-1 is true because it is only used for the registering form so if I have both conditions I know that the form ID will be the registering form of the user.

So if both conditions are met I should only have one result of the entry_id form.

I have tried :

Which was the closest I got but the IN clause makes it so it says OR and I would need both conditions to work.

This one was close as well but it still doesn’t work well.

My table is as follows :

meta_id entry_id meta_key meta_value
– 1297 72 email-1 emailofuser@mail.com
– 1316 72 gdprcheckbox-1 true

I hope I was clear enough, thank you for your help ! 🙂

Advertisement

Answer

You only need to find 1 record, and only when gdprcheckbox-1 is true:

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement