Hi I have a query that will be retrieving the members who have the pay method type is cash and memberstatustype have id’s 2 , 3 , 6 . The query working fine when the members have pay method type is cash and dd and card but it will retrieve the all details of members who dont have paymethod is card and this is my query
SELECT members.member_Id, members.member_Lastname, members.member_Firstname, members.member_PostCode,members.member_Reference, members.member_Dob,30*memberToMship_ChargePerPeriod/DateDiff(memberToMship_EndDate, memberToMship_StartDate) As monthly_amount, mshiptypes.mshipType_Name, mshipstatustypes.mshipStatusType_Name,membertomships.memberToMship_EndDate,IF(mshipOption_Period='year', TIMESTAMPDIFF (YEAR,memberToMship_StartDate, memberToMship_EndDate), TIMESTAMPDIFF (MONTH ,memberToMship_StartDate,memberToMship_EndDate ) ) *memberToMship_ChargePerPeriod As Total
FROM members
LEFT JOIN membertomships ON membertomships.member_Id = members.member_Id
LEFT JOIN mshipstatustypes ON mshipstatustypes.mshipStatusType_Id = membertomships.mshipStatusType_Id
LEFT JOIN mshipoptions ON mshipoptions.mshipOption_Id = membertomships.mshipOption_Id
LEFT JOIN mshiptypes ON mshiptypes.mshipType_Id = mshipoptions.mshipType_Id
WHERE
membertomships.memberToMship_PayMethod='Card' OR mshipstatustypes.mshipStatusType_Id='2' OR mshipstatustypes.mshipStatusType_Id = '3' OR mshipstatustypes.mshipStatusType_Id='6';
can any one pls help me on this ….
am i doing any thing wrong in “OR condition”
Your WHERE clause needs to look like this:
Your original query looks for people who have either one of those:
What you wanted was people who have
AND one of the following: