SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Evangelist Miguel61's Avatar
    Join Date
    Mar 2008
    Posts
    408
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)

    Problem with function_substring-index

    Hi.

    This table MySQL:
    Code:
    A	B	C	D
    0(3)	0(323)	0(970)	0(3120)
    0(1)	0(62)	0(116)	0(610)
    0(1)	0(3)	0(200)	0(100)
    0(4)	0(148)	0(563)	0(1050)
    0(1)	0(1548)	0(206)	0(2720)
    I need this output:
    Code:
    A	B	C	D
    3	323	970	3120
    1	62	116	610
    1	3	200	100
    4	148	563	1050
    1	1548	206	2720
    I try use this function:
    http://dev.mysql.com/doc/refman/5.0/...ubstring-index

    Code:
    SELECT 
    SUBSTRING_INDEX(`A`, '0(', -1)
    FROM t
    Output:
    3)

    Can you help me?

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,341
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    Code:
    SELECT REPLACE(REPLACE(A,'0(',''),')','') AS A
         , REPLACE(REPLACE(B,'0(',''),')','') AS B
         , REPLACE(REPLACE(C,'0(',''),')','') AS C
         , REPLACE(REPLACE(D,'0(',''),')','') AS D
      FROM daTable
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Evangelist Miguel61's Avatar
    Join Date
    Mar 2008
    Posts
    408
    Mentioned
    4 Post(s)
    Tagged
    0 Thread(s)
    Thanks Sir.
    I never got this solution.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •