8
Answers

sql query

darma teja

darma teja

9y
670
1
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)