PDA

View Full Version : Need help with a mySQL query


JamesAB
03-02-2015, 08:52 PM
I'm trying to update Thread Subscriptions so nobody that registered with an e-mail address from domainxyz.com gets e-mail updates.

Something like:
UPDATE " . TABLE_PREFIX . "subscribethread
SET emailupdate = 0
WHERE (emailupdate > 0)
AND ?????????

I'm just not familiar enough with queries to know how to test against a users e-mail address. :o

I'm looking to compare it like this:
AND (email LIKE "%domainxyz.com")

I imagine I need to join the user and subscribethread tables but I'm unsure of the proper syntax.

Any help would be appreciated.

Thanks,
James

kh99
03-02-2015, 09:08 PM
This should work:
"UPDATE " . TABLE_PREFIX . "subscribethread as subscribethread
LEFT JOIN " . TABLE_PREFIX . "user as user ON(subscribethread.userid=user.userid)
SET emailupdate = 0
WHERE (emailupdate > 0) AND email LIKE '%domainxyz.com' "

JamesAB
03-02-2015, 09:27 PM
That works great.
Thank you very much!