Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help with a small SQL problem

Status
Not open for further replies.

button71

Programmer
Nov 8, 2006
69
AU
I have
Code:
SELECT * FROM PTEMP ;
		INTO TABLE pictures ;
		ORDER  BY Fname

I wish to exclude all files except jpg , bmp , tif, gif etc

Can anyone help?

Thanks

William
 
Try the following code. Fieldname in the query represents the field containing the names of the files.

Code:
SELECT * FROM PTEMP ;
        INTO TABLE pictures ;
        where justext(fieldname) $ 'jpg/bmp/tif/gif' ;        
ORDER  BY Fname



 
MM0000,

where justext(fieldname) $ 'jpg/bmp/tif/gif'

As William wants to exclude the specified extensions, you need a NOT in there.

Also, it would be a good idea to wrap the JUSTEXT(fieldname) in a LOWER(), to avoid any issues with case.

Mike


__________________________________
Mike Lewis (Edinburgh, Scotland)

My Visual FoxPro site: www.ml-consult.co.uk
 
Mike,

Button71 wrote :

I wish to exclude all files except jpg , bmp , tif, gif etc

I think he wants to exclude all files other than image files from the query. In other words only image files are to be selected by the query.

Yes, wrapping the statement with LOWER() is required to avoid case issues, the query can be changed to

Code:
SELECT * FROM PTEMP ;
        INTO TABLE pictures ;
        where lower(justext(fieldname)) $ 'jpg/bmp/tif/gif' ;        
ORDER  BY Fname



 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top