我正在尝试找出一种方法来做到这一点:
If (blah = 0 then 'Yes' else if blah = 1 then 'no' else 'maybe')
在mysql.我正在尝试这样做,因为我通过以下方式将所有数据插入到 gridview 中:
Dim strSQL As String
strSQL = "SELECT id, billing_first_name, billing_last_name, billing_email, billing_address, billing_city, billing_state, billing_zip, " & _
"total, price_mode, process_status, 1 as num_of_items " & _
"FROM orders " & _
"ORDER BY created_on DESC, processed_on DESC LIMIT 0, 20;"
Dim dtReader As MySqlDataReader
objCmd = New MySqlCommand(strSQL, objConn)
dtReader = objCmd.ExecuteReader()
grdView.DataSource = dtReader
grdView.DataBind()
如果我可以在上面的 vb.net 代码中而不是在数据库中执行 if/then/else 操作,那就太好了。我更习惯用普通的查询代码这样做。
我目前只能使用 if 和 then else 来完成此操作,而不是 if、elseif 和 then else。
SELECT IF(process_status = 1, 'SUCCEEDED', 'blah') as message, id,...
谢谢!
最佳答案
在 SQL 中,这样做是这样的:
select
case blah when 1 then 'yes'
when 0 then 'no'
else 'maybe' end as blah ,
columnb ,
columnc
from table
关于asp.net - mysql if else 用于 asp.net gridview,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11940816/