Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
カテゴリテーブルとアイテムテーブルがあります。私は約20のカテゴリを持っています。items テーブルには、これらのカテゴリのうち 10 個のアイテムがあります。項目テーブルに項目があるすべてのカテゴリを選択したいと考えています。アイテムがないカテゴリをすべて除外したい。
Items テーブルには、カテゴリの ID フィールドと一致する categoryID フィールドがあります。
select * from categories c inner join items i on i.categoryID = c.id;
また
select * from categories c where c.id in (select i.categoryID from items i);
これを試して
select * from categories c inner join Items I on I.categoryid=c.id