0
SELECT s.srv_id, sp.is_nocommission 
FROM services_param sp
JOIN services s ON (sp.pid = s.id) 
WHERE sp.prefix LIKE '%011%';

我可以得到一个或多个结果。如果srv_idis_nocommission设置为 1(非空),我只需要选择它,无论哪种方式我都需要选择最少。请帮忙。

4

1 回答 1

0

尽管我对您的问题和评论还不够清楚,但您可以尝试以下方法:

SELECT CASE sp.is_nocommission WHEN 1 THEN s.srv_id ELSE MIN(s.srv_id) END
FROM services_param sp
JOIN services s ON (sp.pid = s.id) 
WHERE sp.prefix LIKE '%011%'
于 2013-10-10T10:14:57.210 回答