There is a mysql function called substring_index() that returns a substring based on 
an index character like space ' '. You have to specify the string, the index 
character, and how many time it has to find it from the left or right (left being 
positive and right being negative, I think) before the substring is complete.

Check out:

http://www.mysql.com/doc/en/String_functions.html

for that and other string functions that might be useful.

Carl.

-----Original Message-----
From: Andrew McCombe [mailto:[EMAIL PROTECTED]
Sent: Friday, June 27, 2003 12:06 PM
To: [EMAIL PROTECTED]
Subject: [PHP] mysql split?

Hi

I have a field in mysql that has paths to files such as:

project/entertainment/andrew/job/1.jpg
project/corporate/roberts/job/1.jpg
project/corporate/andrew/job/1.jpg
project/identity/john/job/1.jpg

The first level is always 'projects'.  What I want to do is get the unique
name for the 3rd level for all entertainment, corporate and identity, so
from the data above I would get returned:

andrew
john
roberts

What's the best way to acheive this? I remember seeing something where you
can split a field in the mysql into parts (ie, split at /)?  or would a
regex be better ('WHERE REGEX "^projects/corporate|entertainment|identity/'
(this doesnt work))?  Hope someone can help.




Regards
Andrew McCombe
Interactive Web Solutions (Stafford)
Tel: 01785 279921



----------------------------------------------------------------------------
-------------------------
The contents of this e-mail and any attachments are confidential and may
be legally privileged. If you have received this e-mail and you are not
a named addressee, please inform us as soon as possible on
+44 (0) 1785 279920  and then delete the e-mail from your system. If you are
not a named addressee you must not copy, use, disclose, distribute,
print or rely on this e-mail. Any views expressed in this e-mail or any
attachments may not necessarily reflect those of Interactive Web Solutions'
management.
Although we routinely screen for viruses, addressees should scan this
e-mail and any attachments for viruses. Interactive Web Solutions makes no
representation or
warranty as to the absence of viruses in this e-mail or any attachments.
Please note that for the protection of our business, we may monitor and
read e-mails sent to and from our server(s).



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to