如果列值提供空值,我想從MySQL中的表中檢索所有數據?如果列值提供空值,如何檢索MySQL中的表中的所有數據?
我有一個像國家的表。
如何編寫一個查詢
- 如果
country = ' '
我需要在表格中顯示的所有數據。 - 如果
country='algeria'
,它將顯示特定的數據。
我需要一個查詢中的兩個查詢。
i am getting result .but without providing variable how to write query...
declare @country1 varchar(30)
set @country1 = 'asd'
SELECT country_id, country
FROM country
WHERE ((@country1 = '') or (@country1 != '' and country.country= @country1));
無論這些都無關NULL,你可能知道,當你想「我要這要這是真的做什麼。 ..「 –
你如何將國家參數傳遞給查詢? – jarlh
您可以使用case語句來說明您的條件 – Abhishek