Monday, July 14, 2014

Get first 4 strings of the field in MySQL




I have a MySQL table  fmcontract_sims_courses, and I only want to select the first 4 strings of the field
 CourseDescription_original:
SELECT SUBSTRING(CourseDescription_original, 1, 4) FROM fmcontract_sims_courses

Copy this value to the column Section in  table fmcontract_course_assignment:
UPDATE fmcontract_course_assignment as a,  fmcontract_sims_courses as b  SET a.Section =
SUBSTRING(b.CourseDescription_original, 1, 4)  WHERE a.CRSEID = b.CourseKey

No comments:

Post a Comment