I have written an inner join to pull information from three tables within one database. When I run the query I get two rows returned, the second being a duplicate of the first row. I would expect only one row to be returned?
The query:
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;
returns two rows, whereas this开发者_运维问答 one only returns one row (And is as expected)
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;
I would think that you have two records in application_price
table where the euroapps.id
= 353783927.
Can you verify?
It appears that your application_price table has two rows that are matching.
Try a select from application_price where the foreign key appears twice, and you'll find your culprit.
My guess would be that the application_price table contains two rows for application_id "353783927". What does "select * from application_price where application_price.application_id = 353783927" return. My guess would be you have a schema where application_price specifies difference prices for a euroapp.
You don't seem to be using and values from application_price thought and so I'm not sure why you're joining it.
精彩评论