RSS | Archive | Random | E-mail

About

Hi, I'm Christian Castelli, a 28 years old italian programmer located in Pisa (Italy). Here I post small snippets of code which can be useful in my work.

Links

Codepuzzling main site
Development site
ByteStrike italian blog
Follow me on Twitter

My Life Style

while(passion) {
  try {
    myLife.run();
  }catch(LifeExceptions) {  
    stronger++;
    continue;
   }
}

Following

1 September 09

[SQL] How to concatenate a string with a result of a query

If the subquery returns a string, you can use safely CONCAT operator to join the strings:
SELECT CONCAT('my',(SELECT string
                   FROM table
                   WHERE condition = 1)) as aName
You can use CONCAT_WS if you want to specify a separator for the strings.

Tags: SQL mysql
Comments (View)
  1. codepuzzling posted this
blog comments powered by Disqus
Themed by Hunson. Originally by Josh