Ecommerce Shopify WordPress Discussion

Joining two tables with a where condition that either displays the contents of a cell, or displays "N/A" if where conditions aren't met

I have a form on Wordpress that is creates a table with the field ID of each field, and the meta_value of that field. Each form that is filled out produces a unique item id. How the form from the frontend works is that the parent fills out a form for their family, and creates a student profile within that form for each individual student. On the database side, is that there is a column for the form ID, the field ID, and the contents of that field (meta_value). Within the main family form, there is a field_ID (2309) that contains a string with a list of all the form IDs for the student profiles I mentioned earlier. What I need is to pull the name, behavioral concerns, and medical concerns for each student, as well as whether their parent has given permission for them to have their pictures taken. Then, I need to group these by their classes to create a teacher roster. Here's what I have so far: ` SELECT name.meta_value as "name", behavior.meta_value as "behavior", medical.meta_value as "medical", photos.meta_value as "photos" FROM wp_frm_item_metas name JOIN wp_frm_item_metas behavior ON name.item_id = behavior.item_id JOIN wp_frm_item_metas parent ON parent.meta_value LIKE "%" || name.item_id || "%" JOIN wp_frm_item_metas photos ON parent.item_id = photos.item_id JOIN wp_frm_item_metas class ON name.item_id=class.item_id JOIN wp_frm_item_metas medical ON name.item_id = medical.item_id WHERE name.field_id=2311 AND behavior.field_id=2321 AND photos.field_id=2343 AND class.field_id=2313 AND parent.field_id=2309 AND medical.field_id=2323 GROUP BY class.meta_value I've got it partially working, but I'm encountering two main problems Not every student has medical concerns, and if there are no medical concerns, their student profile will not a row with medical.field_id=2323, therefore they do not show up on this query. I need the query to pull in the meta_value from that specific row otherwise it can be either blank or "N/A" (honestly whichever is easier to do code-wise) every single student account is linking to the same family account for some reason. It's not accurately searching and connecting to the correct family form. I don't know why and I don't know how to fix it. Given those issues, I can't even tell if the sort by class is working or not.
TurboCommerce make the better internet purchasing globaly

Turbo Multi-language Translator

Make the better internet purchasing globaly

Turbosify SEO Speed Booster

5.0 (7) Free plan available
Get better conversions by improving store loading speed Installed

Turbo Multi-language Chat - AI Customer service in one hand

TurboCommerce make the better internet purchasing globaly
Our products

The help you need, when you need it

App by Turbo Engine

3 apps • 5.0 average rating

Turbosify Speed Booster

5.0 (7)
Get better conversions by optimizing shopify store Google page speed Installed

Turbosify Translator for Wordpress Woocommerce

5.0 (74) Free Wordpress Woocommerce Plugin
Translate your wordpress website to multiple language within 1 click, no configuration needed, no No technical required

Grow your business here

Whether you want to sell products down the street or around the world, we have all the tools you need.