SQL Concat,php

时间:2013-07-08 08:38:07

标签: php sql codeigniter concat

这是我的代码

$this->db->select('*, CONCAT(left(card_id, 1 ), right(card_id, 6 )) AS character_id', FALSE);

错误: 遇到错误

Unknown column '1' in 'field list'

请帮帮我!!!

2 个答案:

答案 0 :(得分:0)

似乎您忘了指定您的表名。

请将[tablename]替换为您的表格名称:

$this->db->query('SELECT *, CONCAT(left(card_id, 1 ), right(card_id, 6 )) AS character_id FROM [tablename]');

或:

$this->db->select("*, CONCAT(left(card_id, 1 ), right(card_id, 6 )) AS character_id");
$this->db->from("[tablename]");
$res = $this->db->get();

答案 1 :(得分:0)

试试这种方式

$this->db->select("*, CONCAT(left(card_id, 1 ), right(card_id, 6 )) AS character_id",FALSE);
$this->db->from("table");
$query = $this->db->get();
return $query;