在连接表中使用 WHERE 子句时"column doesn't exist"



ACreditCardbelongs_toaUser.Subscriptionbelong_toUser.

我正在尝试查询belong_toSubscription.statusUser的所有CreditCard"authorized"

select * from credit_cards
join users on users.id = credit_cards.user_id
join subscriptions on users.id = subscriptions.user_id
where subscriptions.status = "authorized"

返回ERROR: column "authorized" does not exist

其中订阅状态="授权"给了我missing FROM-clause entry for table "subscription"

我做错了什么?

SQL 中的字符串文字用单引号 ('表示,而不是像查询中那样用双引号 (") 表示:

select * from credit_cards
join users on users.id = credit_cards.user_id
join subscriptions on users.id = subscriptions.user_id
where subscriptions.status = 'authorized'
-- Here ---------------------^----------^

相关内容

最新更新