Results 1 to 7 of 7
  1. #1
    Join Date
    Nov 2006
    Posts
    3

    Unanswered: How is String 5'9" inserted into a Table

    Hi There,

    You have a string 5'9". How can you insert it to a table?

    create table t1 (c1 integer, c2 char(20))

    insert into t1 (c1, c2) values (1, '5'9"')?

    Thanks,
    Last edited by wow; 06-08-10 at 23:27.

  2. #2
    Join Date
    Feb 2008
    Location
    Japan
    Posts
    3,483
    Code:
    ------------------------------ Commands Entered ------------------------------
    create table t1 (c1 integer, c2 char(20));
    ------------------------------------------------------------------------------
    DB20000I  The SQL command completed successfully.
    
    ------------------------------ Commands Entered ------------------------------
    insert into t1 VALUES(1, '5''9"');
    ------------------------------------------------------------------------------
    DB20000I  The SQL command completed successfully.
    
    ------------------------------ Commands Entered ------------------------------
    SELECT * FROM t1;
    ------------------------------------------------------------------------------
    
    C1          C2                  
    ----------- --------------------
              1 5'9"                
    
      1 record(s) selected.

  3. #3
    Join Date
    Dec 2007
    Location
    Richmond, VA
    Posts
    1,328
    Provided Answers: 5
    Or the better way to do it were design the tables a bit differently and have a column called feet an another called inches. Then put the appropriate symbol in the display.
    Dave

  4. #4
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by dav1mo View Post
    ... a column called feet an another called inches.
    how horribly unstandard

    surely a single column called centimetres would be better

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

  5. #5
    Join Date
    Dec 2007
    Location
    Richmond, VA
    Posts
    1,328
    Provided Answers: 5
    Yes, but then we Americans would have to have a conversion calculator imbeded in our browser. I think quite a few would first need a lesson to convert the feet to inches as well.
    Dave

  6. #6
    Join Date
    Dec 2007
    Location
    Richmond, VA
    Posts
    1,328
    Provided Answers: 5
    WOW,
    I wanted to let you know that storing the data in my "horribly unstandard" 2 columns or in Rudy's single column, will make it much easier for you to find supsects that are within a certain height.
    Dave

  7. #7
    Join Date
    Apr 2002
    Location
    Toronto, Canada
    Posts
    20,002
    Quote Originally Posted by dav1mo View Post
    Yes, but then we Americans would have to have a conversion calculator imbeded in our browser.
    you've already got one

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL

Posting Permissions

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