12 พฤษภาคม 2559

วิธีลบช่องว่างแต่ละคอลัมน์ ในฐานข้อมูล - How to remove all whitespaces from the entire column MYSQL

down voteaccepted
for replace all spaces : ลบช่องว่างทั้งหมดในคอลัมน์
UPDATE `table` SET `col_name` = REPLACE(`col_name`, ' ', '')
for remove all tabs characters : ลบ tab ในคอลัมน์
UPDATE `table` SET `col_name` = REPLACE(`col_name`, '\t', '' )
for remove all new line characters : ลบบรรทัด
UPDATE `table` SET `col_name` = REPLACE(`col_name`, '\n', '')
for remove first and last space(s) of column : ลบช่องว่างข้างหน้าและข้างหลังข้อมูล
UPDATE `table` SET `col_name` = TRIM(`col_name`)