Reputation: 3092
The scenerio of query is
select * from table1 where colName = 'John' and age(select age from
table1) <> 21
Need data with all the row names as John but their age should not be 21.
How to join the same table?
Upvotes: 0
Views: 1239
Reputation: 1492
As other answers suggest, you don't need a self-join for this scenario. However, self joins are possible in SQL
SELECT * from table1 t1,table1 t2 where t1.id=t2.id and t1.name='John' and t2.age <> 21
But you really shouldn't do this for your scenario.
Upvotes: 1
Reputation: 2655
Try this
select * from table1 where names = 'John' and age <> 21
You can check this link to understand how we can join multiple conditions with select
query in ORACLE
.
Upvotes: 6