如何使用 Opencart 数据库中的表之间的联接进行 SELECT?
我正在使用 Opencart 的 1.4.9.4 数据库。由于我对数据库没有经验,我发现结构很奇怪(硬,疯狂)。例如: 如果我需要显示 product
的型号和名称,我需要连接 2 个表 product 和 product_description,类别的方法相同、制造商等 有一个表只有两个字段product_to_category,字段:category_id和product_id。如果我真的应该使用 JOIN,那么我使用了多少个 JOIN 才能使其正常工作? 但一件非常奇怪的事情是进行查询,我获取产品 ID、名称和型号以及类别名称和制造商名称,我不知道如何实现这一点。这将涉及表格,至少我认为: 产品、产品描述、产品类别、类别描述和制造商。 对不起,乱七八糟,但我现在脑子一片混乱!
I'm playing with Opencart's 1.4.9.4 database. And as I'm not experienced with database I find the structure strange (hard,crazy). For example:
if I need to show the model and the name of a product
I need to join 2 tables product and product_description, and the same approach for category, manufacturers etc.
There is a table is only two fields, product_to_category, fields: category_id and product_id. How many JOINs show I use, if I really should use JOINs, to make it work?
But one really odd thing for is to make a query where I get the product ID, NAME and MODEL with CATEGORY NAME and MANUFACTURER NAME, I have no knowledge to achieve that. It would involve the table, at least I think:
product, product_description, product_to_category, category_description and manufacturer.
Sorry for the mess, but my mind is a mess now!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
在opencart中,您将product_id值连接在一起以获得完整的数据行(并使用where子句设置描述的正确语言ID,这样
将从两个表中获取所有数据并使用20的限制正确连接它们products 和语言 1(默认为英语),当然,在 php 中正确编写时,您将需要动态调用一些数据(例如表前缀和语言 id),这样如果您有多种语言或语言,它就可以工作。带有前缀的数据库表。
In opencart you join the product_id values together to get the full row of data (and use the where clause to set the correct language ID of the description, so
That would grab all the data from both tables and join them correctly using a limit of 20 products and the language 1 (default of english). Of course, when writing it properly in php, you will need to call some data dynamically (such as the table prefix and the language id) so it will work should you have multiple languages or database tables with prefixes. Something like
抱歉,我完全忘记了这一点:
MySQL 从 OpenCarts 数据库中选择重复的行
我已经这么问了。
Sorry people I totally forgot about this:
MySQL SELECT Duplicated rows from OpenCarts DataBase
I had already asked that.