我有以下表格:
> organization_表
organizationId | organizationname
>活动表
camp_id | camp_name | adv_id | organizationId
>广告表
adv_id | adv_name
> ad_display表
ad_displayId | adv_id | camp_id |
现在从ad_display表我想要获取这样的记录:
| adv_name | camp_name | organizationname
使用WHERE Condtion作为organizationId ==?
所以基本上我想要广告列表的campaign_id =?
Note: there should be multiple entry for same adv_id in camapign table and same camp_id with multiple entry in ad_display
最佳答案
试试这个:
SELECT ad.ad_displayId,a.adv_name,c.camp_name,o.organizationname
FROM ad_display ad
INNER JOIN advertise a ON ad.adv_id = a.adv_id
INNER JOIN campaign c ON ad.camp_id = c.camp_id
INNER JOIN organization o ON c.organizationId = o.organizationId
WHERE o.organizationId = ?;