2016-11-04 3 views
0

SQLSTATE [42S22]없는 컬럼 : 1,054 알 열 'vpc_order_info'에서 'WHERE 절'(SQL : select `sequa_transaction_id` as `vpc_transaction_no`, `merchant_order_id` as `vpc_order_info`, `date_created` as `yesterday`, `card_number` as `vpc_Card`, `amount` as `vpc_Amount`, `authorization_code` as `vpc_authorizeId` from `ipg_sentry_response` where `merchant_id` = 12136901 and `vpc_order_info` like %-% and `response_code` = 1 and `date_created` between 2016-03-22 and 2016-09-31)열이 발견되지 않음 : 열이 laravel에 정의 1,054 에러에도

아래로 나는 열을 정의하지만이 오류 메시지를 받고 있습니다.

$col = array("sequa_transaction_id as vpc_transaction_no","merchant_order_id as vpc_order_info","date_created as yesterday","card_number as vpc_Card", "amount as vpc_Amount","authorization_code as vpc_authorizeId"); 

    $records = DB::table('ipg_sentry_response')->select($col) 
    ->where('merchant_id', '=', $vpc_Merchant) 
      ->where('vpc_order_info' ,'like', "%-%")    
    ->where('response_code', '=', '1') 
    ->whereBetween('date_created', array($date,$date2)) 
    //->whereBetween('date_created', array($date,$date2)) 
    ->get(); 

사람이? 내가 Laravel 버전 5.2을 사용하고 그것으로 나를 도와주세요 수 있습니다.

+1

'알 수없는 열'vpc_order_info '는 테이블에 정의되지 않은 것을 의미합니다. – devpro

+0

'merchant_order_id '가 테이블에 있는지 확인하십시오. 맞춤법 검사 – Digitlimit

답변

1

별칭이 정의되어 있지만 아직 사용하지 못하고 있습니다. where caluse. group, order ...에 alias을 사용할 수 있습니다. 별칭 대신 열 이름을 사용해야합니다. 시도 - 당신은 HAVING 절, 또는 에 의해, 주문 GROUP의 열 별칭을 사용할 수 있습니다

$col = array("sequa_transaction_id as vpc_transaction_no", 
     "merchant_order_id as vpc_order_info","date_created as yesterday", 
     "card_number as vpc_Card", "amount as vpc_Amount", 
     "authorization_code as vpc_authorizeId"); 

$records = DB::table('ipg_sentry_response')->select($col) 
->where('merchant_id', '=', $vpc_Merchant) 
->where('merchant_order_id' ,'like', "%-%")    
->where('response_code', '=', '1') 
->whereBetween('date_created', array($date,$date2)) 
->get(); 

. 표준 SQL에서는 WHERE 절에서 열 별칭을 참조 할 수 없습니다.