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

Insert String Literal in SQL Output 1

Status
Not open for further replies.

Michael42

Programmer
Oct 8, 2001
1,454
US
Hello,

In Oracle 9i sqlplus, if I have SQL that looks like this:
SELECT user,location FROM mytable and produces something like this:
Code:
user   location
------ --------
bjones Dallas
jsmith Miami


How can I insert text that will not replace a field output but add text description?

Example desired output:
Code:
    user       location
    ------     --------
ABC bjones XYZ Dallas
ABC jsmith XYZ Miami

Thanks,

Michael42
 

Use the concatenation operator:
Code:
SELECT 'ABC '||user,'XYZ '||location FROM mytable;
[2thumbsup]

----------------------------------------------------------------------------
The person who says it can't be done should not interrupt the person doing it. -- Chinese proverb
 
LKBrwnDBA,

Thanks!

Hey one more question on this please...

How can I output single quotes - example desired output:
Code:
    user         location
    ------       --------
ABC bjones 'XYZ' Dallas
ABC jsmith 'XYZ' Miami

Thanks,

Michael42
 
SELECT 'ABC '||user,'''XYZ'' '||location FROM mytable

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top