UPDATE table_name
SET field_name= REPLACE(field_name,'<character to find>', '<character to replace>');
MYSQL - Remove character/blank space in table fields.
MYSQL - Join Table
SELECT a.field1,a.field2,b.field3,b.field4
FROM table1 a, table2 b
where a.field1 = b.field3
Labels:
code,
join,
mysql,
programming,
select
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
SELECT dob,
COUNT(dob) AS NumOccurrences
FROM users
GROUP BY dob
HAVING ( COUNT(dob) > 0 );
Labels:
code,
example,
mysql,
occurrences,
programming,
tutorial
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);
Subscribe to:
Posts (Atom)