2013-10-28 27 views
0

你好,我有下一行的表:SQLite的正则表达式与LIKE

Path  
-------------------     
Archive.zip     
MyFile.zip     
MyFolder     
MyFolder/myfiledata.txt  
MyFolder/otherfile.dat  
OtherFolder 
OtherFolder/otherfile.dat 
OtherFolder/More/filenext.dat 
OtherFolder/Less/filenext.dat 

而且我想使用像,得到的,只有第一级:

Path 
-------------------      
Archive.zip     
MyFile.zip     
MyFolder     
OtherFolder      

会有什么查询与SQLite?

谢谢!

+0

要迂回 - LIKE不*使用或支持正则表达式语法;如果你真的想要正则表达式,sqlite有一个单独的'REGEX'运算符,你实际上不需要这里。 'LIKE'实际上(几乎)是不区分大小写的'GLOB'版本,它使用'%'而不是传统的UNIX'*'。 –

回答

2

也许你需要类似的东西:

SELECT Path FROM PathTable WHERE Path NOT LIKE '%/%' 
0

有时它是最容易想到的,你可能会做的选择逆什么条件。

SELECT Path from YourTable WHERE NOT (Path LIKE '%/%')