0

叫我迂腐,但有没有更优雅的方式来结合所有这些检查?

SELECT * FROM [TABLE1] 
WHERE [path] = 'RECEIVE' 
AND [src_ip] NOT LIKE '10.48.20.10' 
AND [src_ip] NOT LIKE '0.%' 
AND [src_ip] NOT LIKE '127.%' 
ORDER BY [date],[time] DESC; 

对于这样的事情:

SELECT * FROM [TABLE1] 
WHERE [path] = 'RECEIVE' 
AND [src_ip] NOT LIKE IN ('10.48.20.10','0.%','127.%', .... ) 
ORDER BY [date],[time] DESC; 
4

2 回答 2

0

您可以使用正则表达式。在 MySQL 中,这将类似于

select * from [TABLE1]
where [path] = 'RECEIVE'
and [src_ip] not regexp '^(10\\.48\\.20\\.10$|0\\.|127\\.)'
order by [date], [time] desc

在 Oracle 中,它可能类似于

select * from [TABLE1]
where [path] = 'RECEIVE'
and not regexp_like([src_ip], '^(10\.48\.20\.10$|0\.|127\.)')
order by [date], [time] desc
于 2013-10-17T14:18:20.247 回答
0

相关,如果您使用的是 Oracle:

http://asktom.oracle.com/pls/asktom/f?p=100:11:0::::P11_QUESTION_ID:1675747400346669051

于 2013-10-17T15:17:09.813 回答