SQL查询具有多个分类法的drupal节点
大家早上好。 在发布本文之前,我已经阅读了一些建议的问题,但似乎没有人有我同样的问题(可能是我在 Drupal 和编码方面有多糟糕的指标)
我需要编写一个查询,返回所有带有两个节点与之相关的具体分类法(我知道其中的 ID),但似乎我不知道正确的语法,因为我只是设法让它与一个术语 id 一起工作。
这是我到目前为止所拥有的(并且有效)
SELECT * FROM node
INNER JOIN term_node AS tn ON node.vid = tn.vid
LEFT JOIN content_type_extra_content AS xc ON node.vid = xc.vid
WHERE tn.tid IN (SELECT th.tid FROM term_hierarchy AS th WHERE th.tid = '146')
“146”是我需要检查的第一个分类术语的 id(称之为“鞋子”) 现在我必须检查该节点是否还有分类 ID '223'(称之为“季节”),
我尝试了不同的解决方案但无济于事。 我很确定解决方案就在我眼皮子底下,但目前我无法理解它。
请注意,分类法采用不同的词汇表,并且处于 0 级
提前感谢您的帮助
Good morning all.
I've read some of the suggested question before posting this but seems like no one has my same issue (probably and inidicator of how bad I am in Drupal and coding in general)
I need to write a query that returns all the nodes with TWO SPECIFIC taxonomies associated to it (of which I know the IDs), but it seems I don't know the right syntax cause I just manage to get it work with ONE term id.
Here's what I have so far (and works)
SELECT * FROM node
INNER JOIN term_node AS tn ON node.vid = tn.vid
LEFT JOIN content_type_extra_content AS xc ON node.vid = xc.vid
WHERE tn.tid IN (SELECT th.tid FROM term_hierarchy AS th WHERE th.tid = '146')
That '146' is the id of the first taxonomy term I need to check (call it "shoes")
Now I have to check that the node has also the taxonomy id '223' (call it "season")
I've tried different solutions with no avail.
I'm pretty sure the solution is under my nose but at the moment I can't wrap my head around it.
Please note that the taxonomies are in different vocaboularies and they are at level-0
Thanks in advance for any help
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
如果我理解正确的话,您想要具有 2 个特定术语(鞋子和季节)的节点,然后尝试如下操作:
If I understand you correctly, you want the nodes which have 2 specific terms (shoes and season), then try something like this: