Question : Joining issues

Good evening,
Im trying an SQL query to pull a list of all users of all enabled users in a database, the list of users and the enabled status is in two different tables, linked by ID.

The query Im trying to use is:-
select my_aspnet_users.name
FROM my_aspnet_users
left join my_aspnet_users on my_aspnet_users.id = my_aspnet_membership.userId
where my_aspnet_membership.IsApproved = 1


However it returnes:-
#1066 - Not unique table/alias: 'my_aspnet_users'

im not very good at joins between tables, due to not much practise.

Any advise would be appriciated.

Thank you

Answer : Joining issues

select my_aspnet_users.name
FROM my_aspnet_users
left join my_aspnet_membership
on my_aspnet_users.id = my_aspnet_membership.userId
where my_aspnet_membership.IsApproved = 1

You messed up the table name of the table being left joined. It will now include all records from users, regardless if there is a matching membership or not. To make it match both do an inner join.
Random Solutions  
 
programming4us programming4us