How to select and assign the quantity

0

I'm trying to use mysql to select two tables and assign the number of rows to a field eg

I have two tables : Group, Person

I want to make a join in the Group table that shows the number of people assigned to this group through the Group_id field in Person .

Select I did:

SELECT u.* , (SELECT COUNT(*) FROM uniforms where u.id) as quantidade from uniforms_group U

however in return the amount of all rows is being assigned to all fields:

    
asked by anonymous 01.02.2018 / 17:51

1 answer

1

Okay! It was not enough for you to get it right!

The correct query would be:

SELECT U.* , (SELECT COUNT(*) FROM uniforms u0 where u0.id = U.UserId ) as quantidade from uniforms_group U 

    

01.02.2018 / 18:15