select l.lid, GROUP_CONCAT(s.NAME) shopname, m.realname, u.NAME, m.phone, a.name, concat(l.progress,‘‘) from loan l, bank b, merchant m, bank_user u, area a, shop s where l.bid=b.bid and l.mid=m.mid and l.uid=u.uid and b.aid=a.id and l.lid=s.lid GROUP BY l.lid
shop对loan是多对一, GROUP_CONCAT(s.NAME) 可以将一个lid的多个shop.name用“,”拼接起来
字段类型的巧妙转化!
concat(l.progress,‘‘) 将其他类型的progress字段,转化为varchar即String输出!可避免数据从库中取出时的错误(如TINYINT类型取出后为true/false)
时间: 2024-10-09 23:52:32