function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
ThomasGThomasG 

Selecting data from multiple tables

Hello!

I'd like to select the same kind of data from both the Lead and Contact tables, but would like to avoid having to do 2 different queries.
For example, we want to set up some kind of member system, which works in relation with the e-mail address of our leads and contacts. So, I'd like something that'd give a result similar to what you'd get with the UNION keyword in SQL ('SELECT email FROM Lead WHERE email = "xxx@xxx.xx" UNION SELECT email FROM Contact WHERE email = "xxx@xxx.xx"').

If I can't do everything in just one query, that means I'd have to first check if the mail exists in contacts, and if not, then search in leads. It'd be a bit tedious to do that for everything.

Does anyone have a nice solution?

Thanks.