Welcome Guest, Not a member yet? Register   Sign In
trying to use batch_update()
#7

(This post was last modified: 07-30-2020, 09:28 AM by richb201.)

I am still having one more issue.
  $sql = "SELECT * FROM employees ORDER BY RAND() LIMIT " . $count;
        $data = array(
            'in_sample' => 1
        );
        $query = $this->db->query($sql);

        $this->db->set($data);
        $this->db->update('employees');

The query seems to work OK. When I take a look at the result(), I can see that 30 rows are chosen. But when update line runs, it is updating all the rows, not just the 30 that have been filtered. I can see that ALL the rows have in_sample set to one.  Anyone know what I am doing wrong in SQL? Additionally, does anyone know what the seed is for RAND()?

Perhaps I need to loop through the results and update them manually, one at a time?
proof that an old dog can learn new tricks
Reply


Messages In This Thread
trying to use batch_update() - by richb201 - 07-28-2020, 04:49 PM
RE: trying to use batch_update() - by ojmichael - 07-28-2020, 08:58 PM
RE: trying to use batch_update() - by qury - 07-29-2020, 01:22 AM
RE: trying to use batch_update() - by richb201 - 07-29-2020, 08:32 AM
RE: trying to use batch_update() - by richb201 - 07-29-2020, 11:16 AM
RE: trying to use batch_update() - by richb201 - 07-29-2020, 02:52 PM
RE: trying to use batch_update() - by richb201 - 07-30-2020, 09:19 AM
RE: trying to use batch_update() - by ojmichael - 07-30-2020, 04:17 PM
RE: trying to use batch_update() - by richb201 - 08-01-2020, 09:02 AM
RE: trying to use batch_update() - by richb201 - 08-02-2020, 05:23 PM
RE: trying to use batch_update() - by ojmichael - 08-03-2020, 05:55 PM
RE: trying to use batch_update() - by richb201 - 08-03-2020, 06:06 PM



Theme © iAndrew 2016 - Forum software by © MyBB