my users table has columns user_id
, email
invites table has columns invite_id
request_id
user_id
sent_time
when run following query, 2 tables joined 1, expected.
'select * users inner join invites on users.user_id = invites.user_id'
however, when run following query,
'select user_id users inner join invites on users.user_id = invites.user_id'
i following error
operationalerror: (sqlite3.operationalerror) ambiguous column name: user_id [sql: 'select user_id users inner join invites on users.user_id = invites.user_id']
any appreciated.
i think message pretty clear. sqlite doesn't know table user_id
coming from.
one simple solution qualify column name usinga table alias:
select u.user_id users u inner join invites on u.user_id = i.user_id;
another method use using
rather on
:
select user_id users u inner join invites using (user_id);
Comments
Post a Comment