如何编写带有2个条件和在第二个条件内的OR语句的CASE?

时间:2019-06-19 21:00:18

标签: sql case

我正在使用SQL并尝试编写具有两个条件的CASE语句,其中第二个条件具有OR。

我已经尝试在这种情况下使用OR,但它不起作用,我也尝试过使用IN函数,但似乎不支持'%'通配符。

CASE
    WHEN 'Column1' LIKE '%a%' AND 'Column1' NOT LIKE '%b%' OR '%c%' THEN 
         'NewValue'
END 




CASE 
    WHEN 'Column1' LIKE '%a%' AND 'Column1' NOT IN ('%b%', '%c%') THEN 
         'NewValue'

1 个答案:

答案 0 :(得分:1)

import java.io._ import org.apache.commons._ import org.apache.http._ import org.apache.http.client._ import org.apache.http.client.methods.HttpPost import org.apache.http.impl.client.DefaultHttpClient import java.util.ArrayList import org.apache.http.message.BasicNameValuePair import org.apache.http.client.entity.UrlEncodedFormEntity import com.google.gson.Gson case class Person(firstName: String, lastName: String, age: Int) object HttpJsonPostTest extends App { // create our object as a json string val spock = new Person("Leonard", "Nimoy", 82) val spockAsJson = new Gson().toJson(spock) // add name value pairs to a post object val post = new HttpPost("http://localhost:8080/posttest") val nameValuePairs = new ArrayList[NameValuePair]() nameValuePairs.add(new BasicNameValuePair("JSON", spockAsJson)) post.setEntity(new UrlEncodedFormEntity(nameValuePairs)) // send the post request val client = new DefaultHttpClient val response = client.execute(post) println("--- HEADERS ---") response.getAllHeaders.foreach(arg => println(arg)) } 是二进制运算符。您需要在每次使用时都包括两者。然后需要括号。但是,您可能打算:

LIKE