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

Return all fields AND a calced field 1

Status
Not open for further replies.

wjl11

IS-IT--Management
Joined
Jun 20, 2002
Messages
34
Location
US
Hello,

I'm trying to get a query to return ALL fields from a database as well as calced field:

IE:

SELECT *, firstname+lastname as fullname

The syntax above does not work.
Is this possible?

WJL
 
I suggest you use brackets

SELECT
<TableName>.*,
(<TableName>.firstname+<TableName>.lastname) as fullname
From
<TableName>


replace <TableName> with the name of the table
 
WJL, instead of + as the concatenation operator, perhaps you should look up in your database's documentation what the correct operator is

is it the (sql standard) double pipes?

firstname || lastname

is it the ampersand?

firstname & lastname

is it mysql?

CONCAT(firstname,lastname)


rudy
 
If you specify * (for all columns), you are not allowed to specify anything else in th select list. Either you specify * and nothing else, or you have to specify every wanted column
in the select list.

And, as Rudy said, the ANSI/ISO way to concatenate strings is double vertical bars, ||.


/Jarl
 
Oops, I was obviously completly confused when I wrote my previous message.

Do as Nicsin and Rudy says. Forget about my message.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top