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

Add a prefix to a field you select?

Status
Not open for further replies.

JMay0816

Programmer
Mar 1, 2007
34
0
0
US
Can you add a text prefix to a field you select from a select statement?

Example:

Select field1, field2, field3 from table2.

I would like it to look like the following:

field1......field2........field3
Pre-<data> 34 square
Pre-<data> 22 circle


so i want to append "Pre-" to field1.

thx
 
Not sure if I understood your question, but what about string concatenation:
select concat('Pre-',field1), field2, field3 from table2;
 
If you're accessing the values from the resultset by name in your program you'll want to modify that query slightly:
[tt]select concat('Pre-',field1) as field1, field2, field3 from table2;[/tt]

That will preserve field1 as the name for the first record.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top