我需要一个MySQL查询来获得下面预期的输出处理上面的输入数据??(在我的数据中我得到的垃圾数据范围从\ x128到\ x160(十六进制数据)ASCII字符。)所以,我需要一个正则表达式模式只获取包含十六进制值的数据,并保留除键列名称之外的所有值。
<?php
class Home extends CI_Controller {
public function __construct()
{
parent::__construct();
$this->load->model('HomeModel');
// Your own constructor code
}
} <--- THIS IS CLOSING YOUR CONTROLLER CLASS.
function index(){
$query = $this->HomeModel->getEmployees();
$data['EMPLOYEES'] = null;
if($query){
$data['EMPLOYEES'] = $query;
}
$this->load->view('index.php', $data);
}
} <--- IT NEEDS TO BE DOWN HERE.
?>
答案 0 :(得分:0)
首先必须在PHONE列上使用2个查询来获得此结果,第二个是ADDRESS列 1.UPDATE test1 SET Phone = NULL WHERE电话REGEXP&#39; [@ ^]&#39; 2.UPDATE test1 SET Address = NULL WHERE地址REGEXP&#39; [@ ^]&#39;
答案 1 :(得分:0)
HEX(phone) REGEXP '^(..)*[89ABCDEF]'
将匹配任何非Ascii字节的手机。
我怀疑你不是指x128,也不是x160。这些数字看起来更像十进制。如果你想捕获&gt; = 128和&lt; 160(注意:不是&lt; = 160):
HEX(phone) REGEXP '^(..)*[89]'
REGEXP说:
^ -- anchored at start
(..)* -- skip any number of pairs of characters (remember they are hex)
[89] -- match 8x or 9x
-- ignore the rest of the column