gpt4 book ai didi

php - 将表添加到现有查询

转载 作者:行者123 更新时间:2023-11-28 23:26:52 25 4
gpt4 key购买 nike

我有一个表 simsu_subs,其中包含字段 user_id 和到期日期。相同的字段名称 user_id 用于另一个表 mt_links。

我有这个查询完美地工作:

SELECT link_published,
CASE link_published WHEN 1 THEN 'Published' ELSE 'No' END AS 'Published/no',
u.firstname,
u.lastname,
accreditations,
title_descriptor,
phone_number,
display_email,
u.website,
avatar,
logo,
disclaimer,
signature_ie_john_doe,
MAX(IF(lv.cf_id =24, lv.`value`, '')) AS `UploadGraphic`,
MAX(IF(lv.cf_id =36, lv.`value`, '')) AS `Color`,
MAX(IF(lv.cf_id =37, lv.`value`, '')) AS `BodyCopy`,
MAX(IF(lv.cf_id =39, lv.`value`, '')) AS `Salutation`,
l.link_name,
MAX(IF(lv.cf_id =38, lv.`value`, '')) AS `Magazine`,
address,
MAX(IF(lv.cf_id =35, lv.`value`, '')) AS `Address 2`,
city,
state,
postcode FROM cwpc_jsn_users u
INNER JOIN cwpc_mt_links l ON u.`id` = l.`user_id`
INNER JOIN cwpc_mt_cfvalues lv ON l.link_id = lv.link_id
GROUP BY u.firstname, l.link_name

这是我要添加的查询:

SELECT b.expiry_date
FROM cwpc_simsu_subs b
JOIN cwpc_mt_links c
ON b.user_id = c.user_id

我想将 expiry_date 添加到此查询,由 user_id 加入。我试图以比我想数的更多的方式为字段和内部连接起别名。我就是无法让它工作。我在想这条线

INNER JOIN cwpc_mt_links l ON u.id = l.user_id

有关系吗?虽然不完全确定。

有人能指出我正确的方向吗?

谢谢

最佳答案

别名 l 已被使用,所以这可能是您的问题。我希望您的 FROM 子句看起来像:

FROM cwpc_jsn_users u 
INNER JOIN cwpc_mt_links l ON u.`id` = l.`user_id`
INNER JOIN cwpc_mt_cfvalues lv ON l.link_id = lv.link_id
INNER JOIN cwpc_simsu_subs b ON b.user_id = u.id

关于php - 将表添加到现有查询,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38964217/

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