ManuParra
ManuParra

Reputation: 1531

SQLite regular expression with LIKE

Hello I have a table with the next rows:

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

And I want use like, to get, only first level:

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

What will be the query with SQLite?

Thanks!

Upvotes: 0

Views: 743

Answers (2)

Donal Fellows
Donal Fellows

Reputation: 137567

Sometimes it is easiest to think in terms of what you might do to SELECT the inverse.

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

Upvotes: 0

Smileek
Smileek

Reputation: 2782

Probably you need something like that:

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

Upvotes: 2

Related Questions