Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

column width problem

Status
Not open for further replies.

macubergeek

IS-IT--Management
Dec 29, 2004
41
US
Currently I have a database where one column is at maximum width about 255 bytes. That column comes out as one single looooong line. I'd like to reformat this column in SELECT statements to output with the contents line wrapped at say 50 bytes. I've been reading the Dubois book and the mysql online manual and there dosn't seem to a way to do this within mysql...or am I missing something?
Any suggestions would be appreciated. I'm looking for something that dosn't require post processing in php or perl etc.
 
Code:
select concat_ws(
         concat(char(13),char(10))
       , substring(foo,1,50)
       , case when length(foo)>50 
              then substring(foo,51,50) end
       , case when length(foo)>100 
              then substring(foo,101,50) end
       , case when length(foo)>150 
              then substring(foo,151,50) end
       , case when length(foo)>200 
              then substring(foo,201,50) end
       , case when length(foo)>250 
              then substring(foo,251,50) end   
                ) as x
  from yourtable

rudy | r937.com | Ask the Expert | Premium SQL Articles
SQL for Database-Driven Web Sites (next course starts May 8 2005)
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top