Solved

parsing cols in query

Posted on 2006-11-29
3
384 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
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Question has a verified solution.

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

Fore-Foreword Today (2016) Maxmind has a new approach to the distribution of its data sets.  This article may be obsolete.  Instead of using the examples here, have a look at the MaxMind API (https://www.maxmind.com/en/geolite2-developer-package). …
Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikipedia.org/wiki/PHP  Very powerful.  But a…
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…
A short tutorial showing how to set up an email signature in Outlook on the Web (previously known as OWA). For free email signatures designs, visit https://www.mail-signatures.com/articles/signature-templates/?sts=6651 If you want to manage em…

809 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