MYSQL - Insert Select Statement

i use this statement when i want to copy data in selected fields in a table.
INSERT INTO student_subject (subjectid, noofsem)
SELECT subjectid, noofsem FROM study_plan
WHERE student_subject.intakeid = study_plan.intakeid

MYSQL - Update Select Statement

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

MYSQL - count the same value (occurrences) in table

Count number of occurrences in DB 

for example, you want to get how many of users with the same DOB in your DB
COUNT(dob) AS NumOccurrences
FROM users
HAVING ( COUNT(dob) > 0 );

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);