473,386 Members | 1,602 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

REGEXP and MySQL Select: Retreiving What I'm Looking For?

Hi there

If I have a "Filename" column in a database, and I want to grab the
EXTENSION of this filename... can I do it in a query using REGEXP or
something similar?

I've got this going:

"SELECT f.FileID,f.FileName,f.FileName REGEXP '.+\.([^.]+)$' AS FileExt
FROM ProjFiles f
WHERE f.FolderID=584"

But my resulting "FileExt" column just shows a '1' (meaning that yes, a
file extension was found).

Instead of getting a "yes/no" answer from my regexp, can I actually get
the file extension itself?

Thanks!!
Nov 3 '06 #1
1 3135

Good Man wrote:
Hi there

If I have a "Filename" column in a database, and I want to grab the
EXTENSION of this filename... can I do it in a query using REGEXP or
something similar?

I've got this going:

"SELECT f.FileID,f.FileName,f.FileName REGEXP '.+\.([^.]+)$' AS FileExt
FROM ProjFiles f
WHERE f.FolderID=584"

But my resulting "FileExt" column just shows a '1' (meaning that yes, a
file extension was found).

Instead of getting a "yes/no" answer from my regexp, can I actually get
the file extension itself?

Thanks!!
That looks long-winded. Why not have a look at REVERSE

Nov 3 '06 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Martin Lucas-Smith | last post by:
Can anyone point me to a regular expression in PHP which could be used to check that a proposed (My)SQL database/table/column name is valid, i.e. shouldn't result in an SQL error when created? ...
1
by: denisb | last post by:
hello all, for a search engine, I'm looking for a regexp than can do the job it is just (!) a 's' problem (frequent in french) : I have a field 'thesaurus' in a table MySQL (3.23.56) ; I...
0
by: Simon | last post by:
Hi, I have a table with a column that contains many names, like "Ant Simon Lucy", if I was looking for one name in the string of names I would do... SELECT * from classroom where name LIKE...
0
by: Ed Leafe | last post by:
I recently upgraded to 4.1 alpha (MySQL 4.1.0-alpha-standard-log) on my Linux server, and came across a problem with a query that had been working in 3.23 that no longer worked in 4.1a. I've...
6
by: Oliver Spiesshofer | last post by:
Hi, I would like to replace all strings in a table with regexp: the strings contain the substring "-na", and I would like to replace the whole table field with the original content but without...
6
by: Rizyak | last post by:
******************** alt.php.sql,comp databases.ms-sqlserver microsoft.public.sqlserver.programming *********************************** Why doesn't this work: SELECT * FROM 'Events'
1
by: Federico Bari | last post by:
Hello everyone, sorry for my bad English. I have to create a query under mySQL for a small research engine; I have to rate the results of a simple regular expression matches inside a text field....
0
by: problematic | last post by:
Hello guys Actually i dont know does mysql support prepare with regexp but i have this query. prepare stm from "select count(id) as total from products where content regexp ']?]' "; set @a =...
8
by: poolboi | last post by:
hey guys, i got a question on REGEXP in SQL if i have a row containing the info NAME : 12344455667678 how can i use a SELECt with REGEXP
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.