gpt4 book ai didi

mysql - drupal7通过手动sql获取内容

转载 作者:行者123 更新时间:2023-11-29 21:35:22 25 4
gpt4 key购买 nike

我正在尝试使用手动sql方法从drupal7表中获取所有文章,我正在尝试使用名为field_data_bodynode的表>、file_usagefile_management。我真正想要的是这样的:

body_value | body_summary | nid | title | created_time | uri

我使用了以下sql代码:

SELECT distinct body.body_value, body.body_summary, node.nid, node.title, FROM_UNIXTIME(node.created) as created, file_managed.uri
FROM
node
INNER JOIN field_data_body as body ON node.nid = body.entity_id
INNER JOIN file_managed ON file_usage.fid = file_managed.fid
WHERE body.entity_id = node.nid
AND node.type = 'article'
AND node.status = '1'
GROUP BY node.nid
ORDER BY node.nid desc

它有效,但我只得到了那些带有图像文章,而其余的都被忽略了。有人可以建议我如何处理这些 sql 条件吗?

最佳答案

SELECT
b.body_value,
b.body_summary,
n.nid,
n.title,
n.created,
fm.uri
FROM
node n
LEFT JOIN field_data_body AS b ON n.nid = b.entity_id
LEFT JOIN file_usage AS fu ON fu.id = n.nid
LEFT JOIN file_managed AS fm ON fm.fid = fu.fid
WHERE n.type = 'article'
AND n.status = '1'
GROUP BY n.nid
ORDER BY n.nid DESC;

关于mysql - drupal7通过手动sql获取内容,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34965678/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com