Skip to content

Instantly share code, notes, and snippets.

@Linuxpizi
Created May 15, 2020 15:06
Show Gist options
  • Select an option

  • Save Linuxpizi/25e871fc3af6dce4030b8ad4d1f641a2 to your computer and use it in GitHub Desktop.

Select an option

Save Linuxpizi/25e871fc3af6dce4030b8ad4d1f641a2 to your computer and use it in GitHub Desktop.
MySQL条件插入数据

MySQL 条件插入数据

INSERT INTO tbl_employee_info(lname, fname, mname)
VALUES
(
   (CASE lname WHEN '' THEN NULL ELSE lname END),
   (CASE fname WHEN '' THEN NULL ELSE fname END),
   (CASE mname WHEN '' THEN NULL ELSE mname END)
);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment