tl;dr: I am looking for the datatool equivalent of what, in pure SQL, would be SELECT MembershipType FROM members WHERE ID = 1.

I have a problem with datatool. I can load and loop through my db with no problem, but I need to access and check against a specific row. Consider the following MWE:



                  {% begin of db foreach loop
                  \DTLifstringeq*{\MembershipType}{Honorary}{{\ID~\Name: No Payment (Honorary Member)\\}
                      {\ID~\Name: Full Payment (No Parent)\\}
                      Reduced Payment (Parent = \HasParent)\\
                 } % end of db foreach loop


My db consists of five members:

ID Name MembershipType HasParent
1 Alpha Honorary N
2 Bravo Regular N
3 Charly Regular N
4 Delta Regular 2
5 Echo Regular 1

I have both "honorary" and "regular" members, as well as discounts for children, whose parent is also a regular (full) member. Based on the provided sample data, A. should pay nothing (=honorary) while B. and C. pay full. D. pays a reduced fee, because of parent B., but E. should pay full, since his parent A. is not a fee-paying member to begin with.

In my document, I first exclude "Honorary" members, and then check to see if \HasParent == N for all "Regular" members. This works fine, except for Echo: How can I additionally check against Echo's Parent's MembershipType? As I've said above, in SQL a simple SELECT MembershipType FROM members WHERE ID = 1 would suffice, but unfortunately I don't know how to do that with datatool.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.