MySQL query with left join and Date checking

Posted In: . By CreativeSolutions


SELECT p . *, l.lv_Date
FROM `people` AS p LEFT JOIN `leave` AS l
ON p.pl_Personid = l.lv_Tutor
WHERE p.pl_Usertype = 2 AND IF(l.lv_Date != NULL, l.lv_Date Not in ('2012-5-27'), NULL)

 







 The below code can be used to count the number of male/female in the Profile

 Profile.objects.values('gender').annotate(gener_count=Count('gender'))