我有两个MySQL表,一个包含食物,另一个包含食谱(一组食物)。食谱表有一个标题,然后有一个包含该食谱中所有食物的项目表。该表链接到食品表。现在我需要将这些表合并并一起列出。
食品表:
foodid | title | calories 1 banana 100 2 apple 50
食谱表:
recipeid | title 1 fruit-mix
食谱项目表:
receipeitemid | recipeid | foodid 1 1 1 2 1 2
我需要将它们合并为一个列表,其中包含相同列表中的食品和食谱。因此,在上面的示例中,我需要像这样的列表:
title | foodid | recipeid | calories banana 1 null 100 apple 2 null 50 fruit-mix null 1 150
这种合并是否有可能?
食品表:
foodid | title | calories 1 banana 100 2 apple 50
食谱表:
recipeid | title 1 fruit-mix
食谱项目表:
receipeitemid | recipeid | foodid 1 1 1 2 1 2
我需要将它们合并为一个列表,其中包含相同列表中的食品和食谱。因此,在上面的示例中,我需要像这样的列表:
title | foodid | recipeid | calories banana 1 null 100 apple 2 null 50 fruit-mix null 1 150
这种合并是否有可能?