mysql 常见错误记录

1、删除语句使用别名报错:

DELETE   t  from  xt_dispatch_document   t where t.id=20

  上面语句报错


DELETE   from  t  USING xt_dispatch_document    t where t.id=20

  上面语句正常


2、mysql 查询一对多,查询出来不希望不想要太多冗余的行

SELECT * from   t_common_notice  t,
 (
select  common_notice_id  rid ,  GROUP_CONCAT(receiver_name)  rname  FROM   
 t_notice_receiver_info    GROUP BY   common_notice_id
)  r
 where r.rid=t.common_notice_id
如上需要查询出多个人员,把多个人员使用逗号隔开显示,使用 GROUP_CONCAT先分组查询到多个人,在把多个人使用,分割作为一行显示

猜你喜欢

转载自blog.csdn.net/zhangkang65/article/details/79917495
今日推荐