我有一个包含sql语句的字符串,如下所示:
$sql = "SELECT nic_number, client_title, client_lastname FROM customer ORDER BY id_client LIMIT 0, 1";
我想从中删除LIMIT 0, 1
,因为它变为
SELECT nic_number, client_title, client_lastname FROM customer ORDER BY id_client
谢谢你们。
答案 0 :(得分:1)
使用str_replace:
echo str_replace("LIMIT 0, 1", "", $sql);
答案 1 :(得分:1)
$sql = 'SELECT nic_number, client_title, client_lastname FROM customer ORDER BY id_client LIMIT 0, 1';
echo $sql = preg_replace('/LIMIT \d+, \d+/', '', $sql);
答案 2 :(得分:0)
假设内容始终相同:
$sql = str_replace('LIMIT 0, 1', '', $sql);