我编写了一个内连接来从一个数据库中的三个表中提取信息。当我运行查询时,我得到两行返回,第二行是第一行的副本。我希望只返回一行?
查询:
mysql> SELECT euroapps.id, euroapps.name, euroapps.imageurl, euroapps.website,
euroapps.developer, euroapps.description, euroapps.created, euroapps.iphone,
euroapps.ipodtouch, euroapps.ipad, app_detail.screen1 , app_detail.screen2,
app_detail.screen3, app_detail.screen4, application_price.retail_price
FROM euroapps INNER JOIN app_detail ON euroapps.id = app_detail.id
INNER JOIN application_price ON euroapps.id= application_price.application_id
WHERE euroapps.id = 353783927;
返回两行,而这一行只返回一行(并且是预期的那样)
mysql> SELECT euroapps.id, euroapps.name, euroapps.imageurl, euroapps.website,
euroapps.developer, euroapps.description, euroapps.created, euroapps.iphone,
euroapps.ipodtouch, euroapps.ipad, app_detail.screen1 , app_detail.screen2,
app_detail.screen3, app_detail.screen4
FROM euroapps INNER JOIN app_detail ON euroapps.id = app_detail.id
WHERE euroapps.id = 353783927;
答案 0 :(得分:3)
我认为你在application_price
表中有两条记录euroapps.id
= 353783927。
你能验证吗?
答案 1 :(得分:1)
您的application_price表似乎有两行匹配。
尝试从application_price中选择外键出现两次,你会发现你的罪魁祸首。
答案 2 :(得分:1)
我的猜测是application_price表包含两行application_id“353783927”。什么“select * from application_price where application_price.application_id = 353783927”返回。我的猜测是你有一个架构,其中application_price指定了euroapp的差价。
您似乎没有使用application_price中的值和值,因此我不确定您为何加入它。