我有两张桌子:
第一个表是item
,其中包含id列,第二个表是item_description
,其中包含标题列
我希望从项目表中获取不同的行,并从item_description table
我做到了:
SELECT distinct id, item_description.title
FROM (item use index (PRIMARY))
最好的要求是什么?
此致 弗兰克
答案 0 :(得分:0)
嗯,据我所知,你想加入这两个表。这是这样做的:
SELECT distinct it.id, idesc.title
FROM item it
JOIN item_description idesc ON it.id=idesc.item_id;
当然,您需要在item_description
表中添加与id
表格中item
列对应的列。