![]() |
|
Welcome to the Computer Webmaster Gaming Console Graphics Forum forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
| |||||||
| Database Database problems or need to ask a question? maybe something to do with sql injections or a database software question. Database topics cover MySQL, PostgreSQL, Oracle, SQL Server or anything else related to databases. |
![]() |
| | LinkBack | Thread Tools | Display Modes |
| | #1 | ||
| Hello all. I have a field in my table which contains a string that is made of of a series of numbers, followed by an 'arrow' (->), followed by some more numbers. It will look roughly like this : 123->4567 Both the series of numbers before and after the arrow are variable between 1 and 9 numbers. I'm looking for a way to extract the numbers to be able to use them in a view (so it can either be a statement or a function). Looking around, I saw mention of functions like 'LEFT' and 'RIGHT' or 'SUBSTR', but I only found mention of a being able to remove a fixed amount of characters. Does anyone have an idea of how to remove a variable amoung of characters from the string ? Many thanks for any assistance. Anton | |||
|
| Advertisements |
| | #2 | ||
| Mad Ant wrote: > Hello all. > > I have a field in my table which contains a string that is made of of > a series of numbers, followed by an 'arrow' (->), followed by some > more numbers. It will look roughly like this : > 123->4567 As you have the '->', then you can always use a function to locate where it's placed and that way you can know how long the number on the left side is http://dev.mysql.com/doc/refman/5.0/...ction_position As you now easily can determine the length of the string you want, you can use SUBSTR() without any trouble. If you want to make it even simpler, you can use http://dev.mysql.com/doc/refman/5.0/...ubstring-index -- //Aho | |||
|
| | #3 | ||
| On Jun 22, 11:43 am, "J.O. Aho" <u...@example.net> wrote: > Mad Ant wrote: > > Hello all. > > > I have a field in my table which contains a string that is made of of > > a series of numbers, followed by an 'arrow' (->), followed by some > > more numbers. It will look roughly like this : > > 123->4567 > > As you have the '->', then you can always use a function to locate where it's > placed and that way you can know how long the number on the left side is > > http://dev.mysql.com/doc/refman/5.0/....html#function... > > As you now easily can determine the length of the string you want, you can use > SUBSTR() without any trouble. > > If you want to make it even simpler, you can use > > http://dev.mysql.com/doc/refman/5.0/....html#function... > > -- > > //Aho The SUBSTRING_INDEX function is perfect. Thanks loads. Anton | |||
|
| Featured Websites | ||||
|
![]() |
| Tags: amount, characters, remove, string, variable |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
| |
Similar Threads | ||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Remove left hand characters from a field. | Loony2nz | Database | 2 | 07-02-2007 10:59 AM |
| Variable in query string | David & Angela Ehmer | PHP | 2 | 07-01-2007 5:13 PM |
| Using a loop variable as part of another variable name? | MrBoom | PHP | 1 | 07-01-2007 4:12 PM |
| String Manipulation | Steve Perkins | PHP | 3 | 07-01-2007 3:49 PM |
| change some characters into one string | [XaToA] | PHP | 1 | 07-01-2007 3:41 PM |
| Featured Websites | ||||
|