As shown in the picture, I now have 3 tables. tbh and toi are in a one-to-one relationship, and toi and togi are in a one-to-many relationship.
Now I query (the current situation is that a certain row of toi corresponds to 2 rows of togi)
Directly select* only gets one row of data, but
when I select count() gets 2, what's going on? How to write so that count( or other columns) will be 1?
====================================
Because in addition to the number of rows, I also need to get For other values, if it is just the number of rows, I can select * first and then get the size in java. Now I want to get both other values and the number of rows at once
学习ing2017-06-28 09:24:37
You get one row because you used group by. Count is an aggregate function that calculates the number of rows. Group by does not use an aggregate function and only takes the first row of data
某草草2017-06-28 09:24:37
================================Correct answer================ ==================
In this way, you can first query togi according to the conditions to get the results that meet the conditions, and then get the conditions of toi after removing duplicates, and then query toi and tbh