I have to create a query and in that query I need to be able to do this
select if(filename is like .jpg/gif) as type from pictures;
I basically need to send the type of the picture through but they can be either jpg or gif but I don’t know the syntax for the if like condition.
tried this and still nothing
select fileType, IF(fileType LIKE '%.jpg' OR fileType LIKE '%.gif', 'jpg', 'gif')from Pictures ......
+-------------------------+--------------------------------------------------------------------+
| Picture | type |
+-------------------------+----------------------------------------------------
| 1554588136_vibsbujy.jpg | jpg |
| 1554626891_powioojt.gif | jpg |
same result both times
It is not clear what you want returned should the condition be met nor what should be returned if the condition is not met. If all you want to do is filter for files with these extensions then you can do something like: