当前位置:Gxlcms > 数据库问题 > sql not exsit

sql not exsit

时间:2021-07-01 10:21:17 帮助过:4人阅读

        //check the adConsumed table to find whether the same status, status ‘1‘ is in the table, 
        //if the status exsits in the table do not insert that row
        //if the status does not exsit in the table insert the row
        //col2 is the advertisementID calculated from the appinfo with appid
        $sql = ‘INSERT INTO adConsumed(customerID, advertisementID, consumedStatus, consumedTime) 
                select col1, col2, col3, col4
                from (select :customerID as col1, (SELECT `advertisementID` FROM `appInfo` WHERE `ID`= :appid) as col2, 1 as col3, :time as col4) t
                WHERE NOT EXISTS (SELECT * FROM adConsumed WHERE customerID = :customerID and advertisementID = col2 and consumedStatus=1)‘;

        $command = $connection->createCommand($sql);
        $command->bindParam(‘:appid‘, $appid);
        $command->bindParam(‘:customerID‘, $customerID);
        $command->bindParam(‘:time‘, date(‘Y-m-d H:i:s‘));
        $updateSucceeded = $command->execute();

 sql 语句中包含sql语句.

 

sql not exsit

标签:

人气教程排行