2016-11-07 92 views

回答

1
SELECT 
    CASE 
     WHEN city = 'X' 
      THEN 'City' 
     ELSE 'Country' 
    END column_Value 
FROM [table_Name] 
WHERE city = 'X' OR country = 'X'; 

您可以使用上述查詢。

0

select count(*) from tableName where city = "X" or country = "x"

如果返回0,那麼它不存在。

要檢查列則:

select count(*) from tableName where city = "X" 如果返回0,則

select count(*) from tableName where country = "X" 如果返回0,那麼它不存在的國家是不存在的城市

+0

更新的問題。請再看一遍。抱歉給你帶來不便。 – balajiprasadb

+0

我編輯了我的答案 –

+0

然後在問題中指定。 –

相關問題