table A :suit
table B :suit_goods
Association conditions: suit.suit_id = suit_goods.suit_id
Corresponding relationship: A => Multiple B
SQL select How to achieve the above result? ? ? Ask God for enlightenment
Result:
When a record is associated with the suit_goods table, first this record is retained, and other associated data is displayed below
Looking at you, suit_goods should be used as the main table
select ...
from suit_goods g
left join suit s on s.suit_id = g.suit_id
In this way, the data is basically the same as suit_goods, and an additional column of suit.name (this is written casually because I didn’t see the structure of your database) represents the name of the suit to which this good belongs. According to this, the field can be Play freely.