Skip to content
Advertisement

Query to compare/merge two complex queries

I have two queries:

Query #1: get all subscriptions

It returns which username has which subscription

Results:

Query #2: get inactive accounts.

This returns all the inactive users still in the server

Results:

#Main Question: To find all the inactive users having subscriptions.

#I need to check if any values of the “UserName” column in table 2 exists in the “UserName” column of Table 1.

Does anyone know how to do this?

So far I tried joining the two columns but an error occurs every time.

I get this error:

Level 16, State 1, Line 2
Ambiguous column name ‘UserName’

Advertisement

Answer

You need to use correct aliases in the first select statement:

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement