mysql - 请教 sql 语句
PHP中文网
PHP中文网 2017-04-17 11:40:00
[MySQL讨论组]
SELECT * FROM product 

left join product_name on product_name.product_id = product.id
left join product_price on product_price.product_id = product.id
left join name_country on name_country.name_id  = product_name.id
left join price_country on price_country.price_id = product_price.id
where name_country.country_id = 1
and price_country.country_id = 1

表结构如下

想实现本地化(并且需要可排序),所以这么设计,不知道有没有更好的方法。

如何才能不 where 2 个表的 country_id 呢?因为需要本地化的信息还很多,可能拆分出10个小表。这样就需要 where 10 个表的 country_id

PHP中文网
PHP中文网

认证0级讲师

全部回复(1)
怪我咯

粗略看了下,你的这些表,表示的是同一个产品在不同的country有不同的价格吧。

sql 略。

热门教程
更多>
最新下载
更多>
网站特效
网站源码
网站素材
前端模板
关于我们 免责申明 意见反馈 讲师合作 广告合作 最新更新 English
php中文网:公益在线php培训,帮助PHP学习者快速成长!
关注服务号 技术交流群
PHP中文网订阅号
每天精选资源文章推送
PHP中文网APP
随时随地碎片化学习
PHP中文网抖音号
发现有趣的

Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号