darma teja

darma teja

  • NA
  • 496
  • 338.5k

sql query

Mar 1 2015 4:42 PM
Hi all,
I have a  table like this:

Table1

idname        comment
1test        null   
2test1        abc
3test1        def
4TEST2abc
5test3        abc
6test3        def
7TEST4abc

I would like to get all rows
1. where comment='null'
2. if name (Example: test1) has 'abc' and 'def' in comment column than show only where comment= 'def'
3. if name has only 'abc' than show that row


the output should be like this:


idname        comment
1test        null
2test1        def
3TEST2abc
4test3        def
5TEST4abc

How can I write the query for this scenario?


Thanks,
Darma

Answers (8)