Is it possible to search 2 emails in 1 BD call?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
hybris
Forum Contributor
Posts: 172
Joined: Wed Sep 25, 2013 4:09 am

Is it possible to search 2 emails in 1 BD call?

Post by hybris »

Hi,

Im probably tired but is there some elegant solution to search if 2 different emails exist in a DB and sseparate the results in just 1 DB search?

I have a user DB that holds useremail (unique)

I have a form where you can register a company that have like commersialcontactemail (CCEmail) and technicalcontactemail (TCEmail).
When submitting the form i want to search the user db to see if the CCEmail or TCEmail exist and if so add the user id to a field.

I can easily solve this by doing separate searches like first i search if row=1 for CCEmail and then I do another search for the TCEmail. But this means I have to search the DB 2 times (Not a disaster, Im just curious if there is a better way to do this).

((Also I dont mean search if either CCEmail or TCEmail exist because i need to know if its CCEmail or TCEmail so i update in the right column.))

Thanks
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Is it possible to search 2 emails in 1 BD call?

Post by requinix »

If you can't do "email = cc or email = tc" then doing it twice is probably the best way.

Shorter code doesn't always mean better code.
Post Reply