Home > database >  More than about database data one-to-many query problem! Pray god to guide!
More than about database data one-to-many query problem! Pray god to guide!

Time:09-17







This is my three tables of data I want the final results to check each table into the third piece
This is the third picture of the query code so I rewrite
 
The SELECT GROUP_CONCAT (d_name SEPARATOR ', ') drugde FROM department WHERE FIND_IN_SET (d_id, (SELECT drugde FROM drug WHERE drugid=2))




But it's wrong to rewrite so obvious

 
The SELECT drugid, ` drugname `, c.t ypename drugtype, ` drugprice `,
GROUP_CONCAT (b.d _name SEPARATOR ', ') drugde, ` drugre `, ` drugstatus `, ` drugcom `, drugcon
The FROM drug a LEFT JOIN department b ON b.d _id=a. d. rugde
LEFT the JOIN drugdata c ON c.d rugtype=a. d. rugtype


This is the third picture of the query code I think excuse me bosses how to query I want ah ~!!!!!!
Beg you orz!

CodePudding user response:

I am good,,,,

 
The SELECT ` drugid `, ` drugname `, c.t ypename drugtype, ` drugprice `, GROUP_CONCAT (d_name) drugde, ` drugre `, ` drugstatus `, ` drugcom `, drugcon
The FROM drug a LEFT JOIN department b ON FIND_IN_SET (d_id drugde)
LEFT the JOIN drugdata c ON c.d rugtype=a. d. rugtype GROUP BY a. d. rugid



Problem is resolved
  • Related