mysql - Column 'loginAttempts' in field list is ambiguous - what's the difference I'm missing here? -


i have following query working fine - returns user_id table1, , loginattempts , lastattempttime lockouttable.

select user_id, loginattempts, lastattempttime  (     select 'john@blah.com' user  ) u  left join table1  on u.user = a.username left join  (     select attemptedusername, loginattempts, lastattempttime     lockouttable      accounttype = 'public'  ) l on u.user = l.attemptedusername 

i'm using same query on account table - table2, contains user_id , username column same table1. difference i've replaced table1 table2 in query:

select user_id, loginattempts, lastattempttime  (     select 'john@blah.com' user  ) u  left join table2  on u.user = a.username left join  (     select attemptedusername, loginattempts, lastattempttime     lockouttable      accounttype = 'public'  ) l on u.user = l.attemptedusername 

it gives error

column 'loginattempts' in field list ambiguous 

i understand error means haven't prefixed something, why not give error on table1 query when i'm querying virtually same data?

thanks taking look.

what message telling there more 1 table column name , unsure 1 talking about.
want define table in query adding table alias in front of column name have shown in example below. btw example might wrong know 'correct' table column.

select u.user_id, u.loginattempts, u.lastattempttime  (     select 'john@blah.com' user  ) u  left join table2  on u.user = a.username left join  (     select attemptedusername, loginattempts, lastattempttime     lockouttable      accounttype = 'public'  ) l on u.user = l.attemptedusername 

Comments

Popular posts from this blog

javascript - RequestAnimationFrame not working when exiting fullscreen switching space on Safari -

Python ctypes access violation with const pointer arguments -