协助选择

发布于 2024-12-01 20:38:31 字数 526 浏览 3 评论 0原文

我有三个表:hosting_pack、hosting_attr 和hosting_attr_value。

一个hosting_category可以有多个hosting_packs和多个hosting_attributes。

要知道hosting_value,我们必须知道hosting_pack和hosting_attribute,因此hosting_pack包含包信息,hosting_attr包含属性,hosting_attr_value包含一个包中每个属性的值。

描述如下:

在此处输入图像描述

我想显示这样的表格:

hosting_attr,          hosting_attr_value ,           for a given id_hosting_pack

注意:hosting_categ 和hosting_attr 之间的关系并不相同不存在,忽略它即可。

I have three tables: hosting_pack, hosting_attr and hosting_attr_value.

One hosting_category can have many hosting_packs and many hosting_attributes.

To know the hosting_value, we must know the hosting_pack and the hosting_attribute, so hosting_pack contains the pack information, hosting_attr contains the attributes, and hosting_attr_value contains the values of every attribute in one pack.

Described as follows :

enter image description here

I want to display a table like this:

hosting_attr,          hosting_attr_value ,           for a given id_hosting_pack

Note: the relation between hosting_categ and hosting_attr doesn't exist, just ignore it.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

情何以堪。 2024-12-08 20:38:31

试试这个:

select hosting_attr.attr_label, hosting_attr_value.hosting_attr_value from hosting_attr_value, hosting_attr where hosting_attr_value.id_hosting_pack = ? and hosting_attr.id_hosting_attr = hosting_attr_value.id_hosting_attr

如果您不知道id_hosting_pack,您可以在线查找

select hosting_attr.attr_label, hosting_attr_value.hosting_attr_value from hosting_attr_value, hosting_attr where hosting_attr_value.id_hosting_pack = (select id_hosting_pack from hosting_pack where pack_name = ?) and hosting_attr.id_hosting_attr = hosting_attr_value.id_hosting_attr

Try this:

select hosting_attr.attr_label, hosting_attr_value.hosting_attr_value from hosting_attr_value, hosting_attr where hosting_attr_value.id_hosting_pack = ? and hosting_attr.id_hosting_attr = hosting_attr_value.id_hosting_attr

If you do not know id_hosting_pack, you can look it up in-line

select hosting_attr.attr_label, hosting_attr_value.hosting_attr_value from hosting_attr_value, hosting_attr where hosting_attr_value.id_hosting_pack = (select id_hosting_pack from hosting_pack where pack_name = ?) and hosting_attr.id_hosting_attr = hosting_attr_value.id_hosting_attr
安静 2024-12-08 20:38:31
select ha.attr_label, hav.attr_value from hosting_attr ha
inner join hosting_attr_value hav on ha.id_hosting_attr = hav.id_hosting_attr
where hav.id_hosting_pack = :theIdOfTheHostingPack
select ha.attr_label, hav.attr_value from hosting_attr ha
inner join hosting_attr_value hav on ha.id_hosting_attr = hav.id_hosting_attr
where hav.id_hosting_pack = :theIdOfTheHostingPack
时光瘦了 2024-12-08 20:38:31

尝试:

select *
from 
 hosting_pack hp,
 hosting_attr_value hav,
 hosting_attr ha
where
    hp.id_hosting_pack = hav.id_hosting_pack
and hav.id_hosting_attr = ha.id_hosting_attr

是这样吗?

并尝试学习一点 SQL。

Try:

select *
from 
 hosting_pack hp,
 hosting_attr_value hav,
 hosting_attr ha
where
    hp.id_hosting_pack = hav.id_hosting_pack
and hav.id_hosting_attr = ha.id_hosting_attr

Was that it?

And also try to study SQL a little bit.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文