Solved

parsing cols in query

Posted on 2006-11-29
3
387 Views
Last Modified: 2006-11-29
Hello Experts,

Is there a away to write a query in mySQL to parse multiple cols into a single string  col?

like "SELECT (col1 + col2 + col3) aliasName from tbl"

Thank you
Zac
0
Comment
Question by:sacul
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
3 Comments
 
LVL 33

Expert Comment

by:snoyes_jw
ID: 18038561
That's it. Good practice suggests you always use the optional AS keyword to avoid confusion:
SELECT (col1 + col2 + col3) AS aliasName FROM tbl
0
 
LVL 19

Accepted Solution

by:
VoteyDisciple earned 250 total points
ID: 18038677
Actually in MySQL the + operator will try to add the strings and come up with zero.

SELECT CONCAT(col1, col2, col3, 'literals can go in here too') AS aliasName FROM tbl;

... will do the concatenation.
0
 
LVL 1

Author Comment

by:sacul
ID: 18039171
Perfect,

Thank you for the quick answer.
I guess the + sign is trying to do an addition of the strings over a concatenation.

Thank you,
Zac
0

Featured Post

The Eight Noble Truths of Backup and Recovery

How can IT departments tackle the challenges of a Big Data world? This white paper provides a roadmap to success and helps companies ensure that all their data is safe and secure, no matter if it resides on-premise with physical or virtual machines or in the cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

This guide whil teach how to setup live replication (database mirroring) on 2 servers for backup or other purposes. In our example situation we have this network schema (see atachment). We need to replicate EVERY executed SQL query on server 1 to…
Creating and Managing Databases with phpMyAdmin in cPanel.
In an interesting question (https://www.experts-exchange.com/questions/29008360/) here at Experts Exchange, a member asked how to split a single image into multiple images. The primary usage for this is to place many photographs on a flatbed scanner…

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question