SQL Language (MOSC)

MOSC Banner

How to write a query that acces table only once

edited Jul 9, 2015 2:07PM in SQL Language (MOSC) 2 commentsAnswered


Hi everyone,

Lets say I have this table (table A):

PKCOL_1COL_2
1A1
2B1
3C2
4A3
5D3
6E3

When I query this table I know the col_1 value (but I do not know the col_2 value) so I can have this WHERE clause:

SELECT *

FROM A

WHERE COL_1 = 'A';

But what I really want, is all the rows that have the same col_2 value as the col_2 values of the rows WHERE col_1='A'.

Normally to do that I would have a query with a join between table A and itself, as such :.

SELECT a1.* FROM
a a1
INNER

Howdy, Stranger!

Log In

To view full details, sign in to My Oracle Support Community.

Register

Don't have a My Oracle Support Community account? Click here to get started.

Category Leaderboard

Top contributors this month

New to My Oracle Support Community? Visit our Welcome Center

MOSC Help Center