mysql - Update data in database using SQL -
i have 1 table in database. field of table describe below.
id | name | qualification 1 | abc | phd 2 | xyz | mba 3 | ads | mba
now problem related update qualification record. suppose if update record of qualification, should append new value existing value.
for example, going update record of id=1. update "qualification" mca
should add mca
existing record phd
, separated comma. output looks below.
id | name | qualification 1 | abc | phd,mca 2 | xyz | mba 3 | ads | mba
when "qualification" null update should not add comma before mca.
thats bad database design never store data comma separated string, make things messy in future.
you should think of normalizing table student
table should like
- id primary key auto_incremented - name - other columns related student
then table student_qualification
- id primary key auto_incremented - id_student ( id student table) - qualification
so each student can add many qualification possible table , can add/edit/delete data
you can later retrieve data using simple joining table.
Comments
Post a Comment