這是我的sql,但我認爲它太複雜了,也許它不是非常快速和高效?我對嗎?或者,還有更好的方法?有沒有更好的方法來做這個查詢?
SELECT TEventInfoid ,A.TTNum,
CASE WHEN TModelid = 3822 THEN (SELECT title
FROM dbo.sns_event WHERE id=TEventInfoid
)
ELSE (SELECT name
FROM dbo.sns_exhibition WHERE id=TEventInfoid
)
END,
CASE WHEN TModelid = 3822 THEN (SELECT start_time
FROM dbo.sns_event WHERE id=TEventInfoid
)
ELSE (SELECT start_Time
FROM dbo.sns_exhibition WHERE id=TEventInfoid
)
END,
CASE WHEN TModelid = 3822 THEN (SELECT [address]
FROM dbo.sns_event WHERE id=TEventInfoid
)
ELSE (SELECT [address]
FROM dbo.sns_exhibition WHERE id=TEventInfoid
)
END
FROM
T_Ticktets A
WHERE A.TTNum='100229143644'
好吧,我用MSSQL – jasonLam