Solved

parsing cols in query

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

Highfive + Dolby Voice = No More Audio Complaints!

Poor audio quality is one of the top reasons people don’t use video conferencing. Get the crispest, clearest audio powered by Dolby Voice in every meeting. Highfive and Dolby Voice deliver the best video conferencing and audio experience for every meeting and every room.

Join & Write a Comment

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
Introduction Since I wrote the original article about Handling Date and Time in PHP and MySQL (http://www.experts-exchange.com/articles/201/Handling-Date-and-Time-in-PHP-and-MySQL.html) several years ago, it seemed like now was a good time to updat…
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…
This video demonstrates how to create an example email signature rule for a department in a company using CodeTwo Exchange Rules. The signature will be inserted beneath users' latest emails in conversations and will be displayed in users' Sent Items…

760 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now