If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > How is String 5'9" inserted into a Table

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-08-10, 22:23
wow wow is offline
Registered User
 
Join Date: Nov 2006
Posts: 3
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 22:27.
Reply With Quote
  #2 (permalink)  
Old 06-08-10, 22:30
tonkuma tonkuma is offline
Registered User
 
Join Date: Feb 2008
Location: Japan
Posts: 2,193
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.
Reply With Quote
  #3 (permalink)  
Old 06-10-10, 08:08
dav1mo dav1mo is offline
Registered User
 
Join Date: Dec 2007
Location: Richmond, VA
Posts: 782
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
Reply With Quote
  #4 (permalink)  
Old 06-10-10, 10:31
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
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

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
  #5 (permalink)  
Old 06-10-10, 10:38
dav1mo dav1mo is offline
Registered User
 
Join Date: Dec 2007
Location: Richmond, VA
Posts: 782
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
Reply With Quote
  #6 (permalink)  
Old 06-10-10, 10:45
dav1mo dav1mo is offline
Registered User
 
Join Date: Dec 2007
Location: Richmond, VA
Posts: 782
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
Reply With Quote
  #7 (permalink)  
Old 06-10-10, 10:48
r937 r937 is online now
SQL Consultant
 
Join Date: Apr 2002
Location: Toronto, Canada
Posts: 19,524
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

__________________
r937.com | rudy.ca
please visit Simply SQL and buy my book
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On