On Sat, 23 May 2015, Rob Willett wrote: > What I want to do is join the table Users and Perimeter Notifications > together but only if the value of Devices.Holiday_Mode is either non > existent or if Devices.Holiday_Mode does exist and its 0. If > Devices.Holiday_Mode is 1 it means the user is on holiday and don?t send > them anything.
Rob, First, you can set holiday_mode to 0 by default rather than leaving it NULL (unknown). As you wrote, unless the user explicitly sets the mode to 1 the assumption is that its value is 0. After all, it's gotta' be one or the other, right? Second, select * from Devices where holiday_mode == 0. Use that as a sub-query and join users to the results. Now you have a list of user email addresses for only those with holiday_mode of zero. HTH, Rich