Monday, August 15, 2011

Update Select Statement


UPDATE subject_section
SET facultyid =
(SELECT facultyid FROM ref_subject
WHERE subjectid = subject_section.subjectid) 

Thursday, June 16, 2011

PHP array function

Check value exist in array
in_array($value_to_check, $array_to_check);
Check key exist in array
array_key_exists($key_to_check, $array_to_check);

SQL count the same value in selected field

Count number of user with same DOB in DB 
SELECT dob,
COUNT(dob) AS NumOccurrences
FROM members
GROUP BY dob
HAVING ( COUNT(dob) > 0 )