MySQL Forums
Forum List  »  Newbie

Re: Need Help W/ Query
Posted by: Rick James
Date: May 26, 2012 11:26PM

Picking apart "43,45,79,32" is easily done in Perl or PHP. But it is really messy in SQL. It would take a Stored Procedure/Function, which would run miserably slowly.

Two SUBSTRING_INDEX calls to find the start/end of the number
MID() to pick out the number
Other code to handle the first/last number
All of this in a loop to check each number.
Yuck!

In Perl/PHP, the regexp /\b$id\b/ would test for $id being in the string.
Perl could remove it thus (perhaps):
$str =~ s/^$id(,|$)//;
$str =~ s/,$id(,|$)/$1/;
Concise, but knarly.

Options: ReplyQuote


Subject
Written By
Posted
May 22, 2012 03:15AM
May 22, 2012 03:47AM
May 22, 2012 07:36AM
May 22, 2012 06:08AM
May 23, 2012 02:37PM
May 23, 2012 03:43PM
May 23, 2012 05:35PM
Re: Need Help W/ Query
May 26, 2012 11:26PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.