Start your code here
SELECT Y.USER_ID FROM wp_frm_items Y, wp_frm_item_metas Z LEFT OUTER JOIN wp_frm_item_metas AS Z1 On Z.item_id = Z1.item_id Where Y.id = Z.item_id AND Y.id = Z1.item_id And Z.field_id In (17) And Z.meta_value = "2024-08-23" And Z1.field_id In (4125) AND Z1.META_VALUE Is Null
As a general rule, write your SQL in PHPMyAdmin and get it working there first. Once you get it working, copy it and refactor it for Formidable. You also don't mention how you're executing this code.
Start your code here
First SQL
SELECT Y.USER_ID FROM wp_frm_items Y, wp_frm_item_metas Z Where Y.id = Z.item_id And Z.field_id In (17) And Z.meta_value = "2024-08-23"
My try
SELECT Y.USER_ID FROM wp_frm_items Y, wp_frm_item_metas Z LEFT OUTER JOIN wp_frm_item_metas AS Z1 On Z.item_id = Z1.item_id Where Y.id = Z.item_id AND Y.id = Z1.item_id And Z.field_id In (17) And Z.meta_value = "2024-08-23" And Z1.field_id In (4125) AND Z1.META_VALUE Is Null
You don’t need anything from frm_item_metas if all your doing is checking if an entry exists for form b. Just check frm_items for an entry in form b for the targeted user id. If your SQL returns null, there's no entry. If SQL returns a value, there's an entry. This is all you need in PHPMyAdmin:
SELECT * FROM `wp_frm_items` WHERE form_id = "2" and user_id = "4216";
Formidable has ways of retrieving what you want through various hooks.
Where in the process do you want to know the existence of an entry in form b?
Start your code here
SELECT Y.USER_ID, Z1.meta_value FROM wp_frm_items Y, wp_frm_item_metas Z, wp_frm_item_metas Z1 Where Y.id = Z.item_id And Y.id = Z1.item_id And Y.form_id In (2) And Z.field_id In (17) And Z.meta_value = "2024-08-23" And Z1.field_id In (4077) And Y.USER_ID Not In( SELECT Y.USER_ID FROM wp_frm_items Y, wp_frm_item_metas Z Where Y.id = Z.item_id And Y.form_id In (43) And Z.field_id In (4072))
Please login or Register to submit your answer