mysql句型积累

  1. 统计数量(去重)
    SELECT COUNT(DISTINCT common_name) FROM drug;

  2. load file

> load data local infile 'file_path' into table test_table 
> FIELDS TERMINATED BY '\t\t' 
> ENCLOSED BY ” ESCAPED BY ”
> LINES TERMINATED BY '\n\n'  
 > (field1,field2,field3,field4,field5,field6);

若数据中有反斜杠,需要指定 ESCAPED BY ”

  1. mysql对json的支持
  2. SELECT json_extract(obj, '$.name') FROM table_name WHERE field1 =0 and json_extract(json_field, '$.name') is not null;
  3. update table_name set json_field = json_set(json_field, '$.country', '德国', '$.name', '乳糖') where id = 12505031;

你可能感兴趣的:(mysql句型积累)