Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/mysql/56.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
php找到字符串中的最后一个括号并在其前面插入文本_Php_Mysql - Fatal编程技术网

php找到字符串中的最后一个括号并在其前面插入文本

php找到字符串中的最后一个括号并在其前面插入文本,php,mysql,Php,Mysql,有人能帮我吗 我有一个简单的查询和子程序​​查询。在子查询中,我想修改where和限制。如何在查询中找到最后一个“)”并在其前面放置“限制10” 在程序中可以得到的子查询的示例 我确实有“$Qstring=array_pop(explode('),$Qstring));” 故意有点冗长,但它确实起到了作用。您的PHP代码与SQL非常相似。你确定是PHP吗?当然是PHP!你看不到支架打开(和关闭)了吗? SELECT QE.Maand, QE.Week, QE.`Opz

有人能帮我吗

我有一个简单的查询和子程序​​查询。在子查询中,我想修改where和限制。如何在查询中找到最后一个“)”并在其前面放置“限制10”

在程序中可以得到的子查询的示例

我确实有“$Qstring=array_pop(explode('),$Qstring));”


故意有点冗长,但它确实起到了作用。

您的PHP代码与SQL非常相似。你确定是PHP吗?当然是PHP!你看不到支架打开(和关闭)了吗?
 SELECT 
    QE.Maand,
    QE.Week,
    QE.`Opzegging direct`,
    QE.`Opzegging einddatum`,
    QE.Totaal,
    QE.`Nieuwe Leverancier`
    FROM
    ( select
    MONTHNAME(calldate) as Maand,
    WEEKOFYEAR(calldate) as Week,
    O1.description as "Omschrijving", 
    COUNT(CASE WHEN O1.description ="Opzegging per direct" THEN 1 END)        AS "Opzegging direct",    
    COUNT(CASE WHEN O1.description ="Opzegging per einddatum" THEN 1 END)        AS "Opzegging einddatum",  
    COUNT(CASE WHEN O1.description ="Opzegging per einddatum" OR O1.description ="Opzegging per direct" THEN 1 END) as Totaal,
    COUNT(CASE WHEN O1.description ="Behouden" THEN 1 END)        AS "Behouden",
    O2.description as "Nieuwe Leverancier" 

    FROM best.prj_004_table LEFT OUTER JOIN best.prj_004_options O1 ON best.prj_004_table.rs_retentieresult = O1.value
    LEFT OUTER JOIN best.prj_004_options O2 ON best.prj_004_table.rs_newsuplier = O2.value 

     O2.description is not NULL  AND year(calldate) = year(CURDATE()) AND MONTH(calldate) = MONTH(CURDATE())    GROUP BY O2.description ORDER BY WEEK(calldate)  ) QE
$sql = 'SELECT * FROM (SELECT col1, col2 FROM table JOIN table2 ON col3=col4)';
$limit = ' LIMIT 5';
$position = strripos($sql ')');
$end = substr($sql, $position);
$replace = substr_replace($sql, $limit, $position);
$replace .= $end;