Web Analytics Made Easy -
StatCounter Shortening Data - CodingForum

Announcement

Collapse
No announcement yet.

Shortening Data

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Shortening Data

    If you have the data in "column X" = NNGS0182 is there a way to run a query to just pull characters 2-5. (ngs0) or maybe even create a stored procedure to in insert NNGS0182 as NGS0.

    Thanks

  • #2
    The best way to do this is to probably use PHP before inserting teh data as you suggested. The code below will do that for you

    PHP Code:
    $string "NNGS0182";
    $string substr($string14); 
    For more info see www.php.net/substr

    Jee
    Jeewhizz - MySQL Moderator
    http://www.sitehq.co.uk
    PHP and MySQL Hosting

    Comment


    • #3
      You can do this using MYSQL

      SELECT SUBSTRING('NNGS0182',2,4);


      The layout is like this: SUBSTRING(str,pos,len)
      You can find more about this at



      Hope this helps
      wabirdman
      www.myspace.com/lostsaintsrocks

      Comment


      • #4
        True, but its easy to do this before you enter, otherwise it has to be truncated each time the page loads, and if you're alking 100's of hits, then its ading to server load

        Jee
        Jeewhizz - MySQL Moderator
        http://www.sitehq.co.uk
        PHP and MySQL Hosting

        Comment


        • #5
          Yes that is true. I normally use ORACLE, so I dont really worry that.

          wabirdman
          www.myspace.com/lostsaintsrocks

          Comment


          • #6
            Originally posted by Jeewhizz
            True, but its easy to do this before you enter, otherwise it has to be truncated each time the page loads, and if you're alking 100's of hits, then its ading to server load
            That's only a valid concern if your assumptions about the use of that MySQL statement in context of the application is equal to what BillL thought of. In other words, only when you read out something for presentational display. Also, can you make sure that the "column X" is not used in other contexts where the full string of it's fields is needed? I mean, why should one devise it to store such a content if only a part if it would be actually needed.

            I *suspect* that BillL *might* use it in an insert that relies on values retrieved by [..] JOIN statements. If that's the case, go with wabirdmans suggestion. So it's up to you BillL to clarify your question.
            Last edited by mordred; Jun 19, 2002, 03:16 PM.
            De gustibus non est disputandum.

            Comment

            Working...
            X