DEV Community

Nagarajan R
Nagarajan R

Posted on

Answer: Reduce time for update query in Laravel (without for loop, for same key and multiple values)

As I suggested in the comment, one method is to refactor using a CASE WHEN clause.

You should be able to use a DB:raw select statement with your update method call.

$data = '(SELECT CASE Bib_no';
foreach ($ids as $i => $id) {
    if (!array_key_exists($i, $chestnos)) {
        /* uncomment to

Top comments (0)