mysql three tables union query result set and

reference:

mysql result set to be merged into one line, and duplicate values

SQL joint investigation three tables

Three tables join query the database how to do

merge:

Group_concat function in MySQL

The full syntax is as follows:

GROUP_CONCAT (Field [Order BY ASC / DESC sort field] [the DISTINCT] connected to [Separator 'delimiter'])

Three tables related query:

Example:

There are three tables C B A 
c.aid corresponds a.aid 
c.bid correspond b.bid
select  a.aname, b.bname, c.cname  from  c  
inner join a on c.aid=a.aid inner join b on c.bid=b.bid
 
select a.anme, b.bname, c.value
from a,b,c
where a.aid = c.aid and b.bid = c.bid
Combat:
select b.id,GROUP_CONCAT(a.m_name SEPARATOR' '),b.b_name from t_medicinal_info a, t_product_base b, t_medicinal_productbase c 
where a.id=c.t_medicinal_id and b.id=c.t_product_base_id group by b.id

 

Guess you like

Origin www.cnblogs.com/flypig666/p/11788391.html