mysql cascade query
某草草
某草草 2017-06-22 11:54:37
0
3
908

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

某草草
某草草

reply all(3)
phpcn_u1582
select ...
from suit s
right join suit_goods g on s.suit_id = g.suit_id
大家讲道理

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

Peter_Zhu
SELECT
    `B`.*,
    `A`.`name`
FROM
    `suit_goods` `B`
LEFT JOIN
    `suit` `A`
ON
    `A`.`suit_id` = `B`.`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.

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template