Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to update a column by multiplying other 2 columns of each row? #962

Open
CherukuriSiva opened this issue Mar 19, 2021 · 0 comments
Open

Comments

@CherukuriSiva
Copy link

CherukuriSiva commented Mar 19, 2021

I want to update one Cell in the row, by multiplying some other 2 cells like below.

UPDATE yourTable yt SET yt.Total = (yt.Pieces * yt.Price)

I tried below code:

   ` $last_id = $this->db->rawQuery('UPDATE bet_users_info bui SET bui.profit_amount = (bui.bet_amount * bui.cashout) where bui.betid = ?', 2);`

But I am receiving the error Undefined offset: 1 in \vendor\thingengineer\mysqli-database-class\MysqliDb.php on line 2056

I have no idea how to achieve this without Raw Query:

`        $update_profits_data = array(
            "profit_amount" => $bet_info_row["bet_amount"] * $bet_info_row["cashout"],
        );
        $this->db->where('betid', $bet_info_row["id"]);
        $last_id = $this->db->update('bet_users_info', $update_profits_data);
`

```Kindly let me know how to proceed further.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant