hi I have a table structure thus:
mysql>DESC file;
file_id
fullpathname
with records
file_id | fullpathname
--------+------------------------------------------------------
6 | /var/tmp/4x4 and 6x4/test/test3.txt
7 | /var/tmp/4x4 and 6x4/test/somefile
8 | /var/tmp/4x4 and 6x4/test
9 | /var/tmp/4x4 and 6x4/6x4_1.JPG
10 | /var/tmp/4x4 and 6x4/6x4_2.JPG
11 | /var/tmp/4x4 and 6x4/4x4_2.jpg
12 | /var/tmp/4x4 and 6x4/4x4_1.jpg
13 | /var/tmp/dir/4x4 and 6x4
and the query needs to be pretty much what I have below (but it’s not working)
SELECT * FROM file
WHERE fullpathname LIKE '/var/tmp/4x4 and 6x4%'
AND fullpathname NOT LIKE '/var/tmp/4x4 and 6x4/%/'
but it needs to NOT return the file_id 6 and 7 it needs to only select “paths” one node deep. It’s a weird one but this is the situation
what it should return is
file_id | fullpathname
--------+------------------------------------------------------
8 | /var/tmp/4x4 and 6x4/test
9 | /var/tmp/4x4 and 6x4/6x4_1.JPG
10 | /var/tmp/4x4 and 6x4/6x4_2.JPG
11 | /var/tmp/4x4 and 6x4/4x4_2.jpg
12 | /var/tmp/4x4 and 6x4/4x4_1.jpg
13 | /var/tmp/dir/4x4 and 6x4
Try this: