lakshay lakshay - 3 months ago 16
MySQL Question

How to concate two columns as one with a space betwen them while using CDbCommands in Yii?

The query I have written is:

Yii::app()->db->createCommand($sql)->queryAll();


where

$sql= 'SELECT `EMAIL` as `EMAIL_ADDRESS`, concat(`FIRST_NAME`, `' '` ,`LAST_NAME`) as `FULL_NAME`, `PHONE_NUMBER` FROM `claim_request`';


What I want to do is FULL_NAME = Mark Taylor. But CDbcommand is not adding space it gives the output as FULL_NAME = MarkTaylor.

Answer

Use this,

$sql= 'SELECTE MAIL as EMAIL_ADDRESS, concat(FIRST_NAME," ",LAST_NAME) as FULL_NAME, PHONE_NUMBER FROM claim_request';

Instead of single quotation mark, you can use double quotation mark...

Comments