Personally, I'd split that into 2 fields. I think that's a better way to model the data unless there's something I don't know.

Otherwise, try this:

mysql> select * from url;
+-----------------------------------------------+
| url                                           |
+-----------------------------------------------+
| <a href="http://www.alabama.gov";>Alabama</a>  |
| <a href="http://access.wa.gov";>Washington</a> |
+-----------------------------------------------+
2 rows in set (0.00 sec)

mysql> select substring(url,locate('">',url)+2, char_length(url)-locate('">',url
)-5) as state from url;
+------------+
| state |
+------------+
| Alabama |
| Washington |
+------------+
2 rows in set (0.00 sec)


mysql>


What I had to to was to have mysql take the string:

<a href="http://www.alabama.gov";>Alabama</a>

and give me the parts between "> and </a>. First, I had to find the position of "> and then add 2 to it. The substring function in mysql takes the parameters string, starting_position, and length. Using locate, I got the starting postion and added 2 to it. For length, I had to use locate again; locating "> gives me the position of the " in ">. Subtracting 5 gives me the right length after discounting the </a> and the 2 positions I'm off from ">.


Someone more experienced that I can tell you if there's a more effecient way. My inclination would be that for best results, you should split the field in two and build your webpage like this:


<a href="$URL">$STATE</a>

Hope this helps.

bob


David Blomstrom wrote:

Suppose I have a field with the names of states,
linked to their home pages:

<a href="http://www.alabama.gov/";>Alabama</a>
<a href="http://access.wa.gov/";>Washington</a>

If I display this on a webpage, I'll get the names of
the states, linked to their home pages. But is there a
simple strategy that will let me to display the names
UNLINKED on another page, or do I have to create a
second field that lists simple state names, with no
URL's?

Thanks.




__________________________________
Do you Yahoo!?
New and Improved Yahoo! Mail - 100MB free storage!
http://promotions.yahoo.com/new_mail





--
MySQL General Mailing List
For list archives: http://lists.mysql.com/mysql
To unsubscribe:    http://lists.mysql.com/[EMAIL PROTECTED]



Reply via email to