Question Details

Browse

how to break a field into two in SQL

By kaku de mel - May. 06, 2008

how to break a field into two in SQL


Answers

Add Answer
  1. By Randy Clark on May. 06, 2008

    Please provide more detail. Do you mean read the value and then manipulate it in some way? What is the type of the field?


    1 Votes
  2. By Joe Mendis on May. 06, 2008

    You probably are looking for substring operation on the strings. For example if you have a field 'ssn' from table customer that returns a Social Security Number in the form 123-45-6789 and you want the first three and last four digits:


    mysql> SELECT SUBSTRING(ssn,0,3) as first3, SUBSTRING(ssn,7,4) as last4 FROM customer;


    Check out the following for more in depth directions:

    http://dev.mysql.com/doc/refman/5.0/en/string-functions.html


    2 Votes
Share your knowledge

Related Questions

Browse Get answers and share your expertise.