Re: [SQL ] Like 后的count计算

楼主: bohei (run and fall)   2014-01-21 17:51:25
2.
SELECT ID,COUNT(*) FROM (SELECT ID FROM tab WHERE ItemNum LIKE '%60001%'
UNION ALL
SELECT ID FROM tab WHERE ItemNum LIKE '%60003%'
UNION ALL
SELECT ID FROM tab WHERE ItemNum LIKE '%60005%')
GROUP BY ID
不知还有没有更精简的写法,还请大家指教,谢谢!
作者: CGS0 (Mike Chen)   2014-02-03 20:59:00
用 or 取代 union

Links booklink

Contact Us: admin [ a t ] ucptt.com