2013-01-16 123 views
0
SELECT 
    case_id, 
    serialnumber, 
    DateLastHere, 
    Bookedindate, 
    DATEDIFF(DateLastHere,Bookedindate) 
FROM `cases` 
WHERE serialnumber like 'TTTT46' 

回答

3

你可以像下面這樣做

$data = array(
      'case_id', 
      'serialnumber', 
      'DateLastHere', 
      'Bookedindate', 
      'DATEDIFF(DateLastHere,Bookedindate)' 
      ); 
$this->db->select($data); 
$this->db->from('cases'); 
$this->db->like('serialnumber','TTTT46'); 
$query = $this->db->get()->result_array();