gpt4 book ai didi

SQL SHOW one more column name FROM operator in

转载 作者:行者123 更新时间:2023-11-29 05:43:53 25 4
gpt4 key购买 nike

我需要显示来自 IN 的列 运算符
我的查询是:

    SELECT prizes.type,prizes.name
FROM lottery_payment_prizes payment
JOIN lottery_prizes prizes ON
prizes.id = payment.prize_id
WHERE payment.payment_id IN
(( SELECT id FROM lottery_payments
WHERE lottery_id = (SELECT id FROM lotteries WHERE abbr = 'TR' AND group_id = '3' )))

结果是:alt text

我的问题:如何显示 lottery_payments 中的两列,lottery_payments 只返回 ID 给 IN 运算符

函数。
我需要显示 lottery_payemnts 表中的列名称“place”。
谢谢大家。

最佳答案

如果您需要来自 lottery_payments 的列,您需要向其添加一个连接:

SELECT payments.place, payments.id, prizes.type, prizes.name
FROM lottery_payment_prizes payment
JOIN lottery_prizes prizes ON
prizes.id = payment.prize_id
JOIN lottery_payments payments ON
payment.payment_id = payments.id
WHERE lottery_id = (SELECT id FROM lotteries WHERE abbr = 'TR' AND group_id = '3' )

关于SQL SHOW one more column name FROM operator in,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4386288/

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