ACreditCard
belongs_to
aUser
.Subscription
也belong_to
User
.
我正在尝试查询belong_to
Subscription.status
User
的所有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 ---------------------^----------^