Tôi bị bệnh khi cố gắng kết nối với MSSQL, vì vậy tôi chuyển sang mysql. Tiến trình chậm. Đây là đoạn hiện tại của tôi: mssql:trường hợp trong một trường hợp được chọn trong mysql
create function W(m varchar(255)) returns int begin
declare @e int
set @e = (select COUNT(N) from P where N = m)
declare @t int
set @t = dbo.C(m)
return case @t
when 0 then -1
when 1 then
case @e when 0 then -1 else 1 end
when 2 then
case @e when 1 then -1 when 2 then 0 when 3 then 0 when 4 then 1 end
when 3 then
case @e when 1 then -1 when 2 then 1 end
when 4 then
case @e when 1 then -1 when 2 then 0 when 3 then 1 end
end
end
Tôi muốn chuyển điều này sang mysql. Có cách mysql hợp lệ để:
select select case n when 0 then 1 when 1 then 2 end into var
? Làm thế nào về
set var = select case n when [...] end
?
Ồ, tôi thấy các AS. Cám ơn rất nhiều! –