我有一张如下表。
一张用于存放水果的桌子,一张用于存放水果的桌子。
create table fruits(fruit_id int, fruit_name VARCHAR(255));
create table type(fruit_id int, status VARCHAR(255));
INSERT INTO fruits(fruit_id, fruit_name)
values(101, 'Apple'),
(102, 'Mango'),
(103, 'Lemon'),
(104, 'Grape'),
(105, 'Orange');
INSERT INTO type(fruit_id, status)
values(101, 'Edible');
(101, 'Sweet'),
(102, 'Edible'),
(103, 'Edible'),
(103, 'Salty'),
(103, 'Sour'),
(104, 'Sour');
现在我想要一个如下所示的输出
Fruit_id FruitName
101 Apple
102 Mango
103 Lemon
104 Grape
我用过INNER JOIN
,但苹果、柠檬和葡萄的重复行
SELECT fruits.*
FROM fruits INNER JOIN type
ON type.fruit_id = fruits.fruit_id