Home > database >  How statistical user table all users of consumer information
How statistical user table all users of consumer information

Time:10-24

There is A user table A
Uid name

There is another consumption table B
The bid uid bfee

How will the user table in table B have consumption records retrieved to all users

thank you

CodePudding user response:

Select * from a where the exists (select 1 from b where a.u id=b.u id)

CodePudding user response:

Consumer of user information
Select a. * from a a inner join (select uid from group B by uid) B on a.u id=b.u id

User + consumption
Select a. *, b.s umFee from a inner join (select sum (bfee) as sumFee, uid from group B by uid) B on a.u id=b.u id
  • Related