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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

truncate values in query

Status
Not open for further replies.

pondi

Programmer
Jun 6, 2001
32
GB
I'll display my query in an HTML table but some values are too long (70 characters)... I'd like to know if it's posiible to truncate these fields in the query.
NB: I don't want to modify my DB design!!
 
Hiya,

Yes, you can truncate a text field in a query. For example, assume that the field whole_address is 80 characters long, to view just the left 50, you would use:

SUBSTRING(whole_address,1,50)

Where the first number (in this case 1) is the starting point from the left, in this case, the first character (but does not have to be) and the 50 is the number of characters you are going to view. To view the last 50, it would just be

SUBSTRING(whole_address,30,50)

HTH

Tim
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top