programing

mariadb: 업데이트에서 "IN" 폐쇄 쿼리 실행

mailnote 2023. 9. 3. 16:31
반응형

mariadb: 업데이트에서 "IN" 폐쇄 쿼리 실행

MariaDB에서 이 쿼리를 어떻게 업데이트합니까?

쿼리:


    UpdatewarehouseBinOfItems() {
        return `UPDATE producedItem
                SET warehouseBinId = ?
                WHERE id IN (?)`;
    }

쿼리를 처리하는 함수:

UpdatewarehouseBinOfItems(id, binId, response, promises) {
        return new Promise(async function(resolve) {
            promises.push(
                db.batch(
                    new WarehouseSQL().UpdatewarehouseBinOfItems(),
                    [binId, id],// this is the way i have used that in mysql but in mariaDB this doesn't 
                                //work :(
                    (error, data) => {
                        if (!error) {
                            console.log(`data from & id lenght ${id.length} && ${JSON.stringify(data)}\n`)
                            resolve(data);
                        } else {
                            console.log(error);
                            return response
                                .status(404)
                                .json(msgs.get("warehouse_bin_Update_failed"));
                        }
                    }
                )
            );
        });
    }


데이터 전달 중:

binId = 1,
id =[8273,57037,57038,57039,57040,57047,57048,57049,57050,57051,57052,57053,57054,57137,57138,57139,57140]


위의 쿼리는 MySQL에서 잘 작동하지만, 제가 MariaDB로 이동하려고 하고 변경 작업을 하고 있기 때문에 위와 같은 쿼리를 처리할 수 없습니다. :( 함수를 루프하지 말고 다른 솔루션을 사용하십시오.

언급URL : https://stackoverflow.com/questions/64422009/mariadb-execute-in-closure-query-in-update

반응형