How do I combine 2 select statements into one?

后端 未结 8 2186
执念已碎
执念已碎 2020-12-23 13:23

I am a noob when it comes to SQL syntax.

I have a table with lots of rows and columns of course :P Lets say it looks like this:

      AAA BBB CCC DD         


        
8条回答
  •  自闭症患者
    2020-12-23 14:19

    use a case into the select and use in the where close a OR

    something like this, I didn't tested it but it should work, I think...

    select case when CCC='D' then 'test1' else 'test2' end, *
    from table
    where (CCC='D' AND DDD='X') or (CCC<>'D' AND DDD='X')
    

提交回复
热议问题