【问题标题】:concat of two colums in left join query左连接查询中两列的连接
【发布时间】:2015-11-04 12:46:28
【问题描述】:
$select->columns(array('TableReservationId', 'TableId', 
                       'ReservationDate', 'StartTime', 
                       'NumberOfGuests', 'AdditinalInfo', 
                       'StaffID', 'MerchantId', 'cust_id'
                       )
                 );

$select->join($cus, "$dtr.cust_id=$cus.cust_id", 
                    array('cust_firstName','cust_lastName'),
                    'left');

$select->join($mer, "$dtr.MerchantId=$mer.MerchantId", 
                     array('FirstName','LastName'),
                    'left');

$select->join($staff, "$dtr.StaffID=$staff.StaffID", 
                      array('FirstName','LastName'),
                      'left');

这是我想要的查询concat (FirstName,'' ,LastName ) as customer_name concat (FirstName,'' ,LastName ) as Employee_name我该怎么做?

【问题讨论】:

  • yes........它只用于单个查询/表......但我正在使用连接多个表并从左表列值我想连接
  • 你在这里使用什么 ORM?也许您需要转储到原始 SQL 命令。

标签: php mysql sql email zend-framework


【解决方案1】:

你不能把它放在选择中吗?如:

(FirstName + '' + LastName) as Employee_Name

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2013-02-25
    • 2021-12-25
    • 2017-06-30
    • 2017-12-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多