CodeIgniter Forums
How to remove the first word From Mysql Table? - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5)
+--- Forum: Best Practices (https://forum.codeigniter.com/forumdisplay.php?fid=12)
+--- Thread: How to remove the first word From Mysql Table? (/showthread.php?tid=79189)

Pages: 1 2


How to remove the first word From Mysql Table? - litecoin90 - 05-07-2021

Hello all codeigniters,

For example A table ('Items') have a column "Coupon_codes". which contains values -

Code:
Start
JkLkLKLLk65
Flashsale2021

I want to delete Start and make it.


Code:
JkLkLKLLk65
Flashsale2021


is that possible to do this using mysql query? How can i do that?


RE: How to remove the first word From Mysql Table? - php_rocs - 05-07-2021

@litecoin90,

Yes it is possible to do that. Please show us your current SQL statement.


RE: How to remove the first word From Mysql Table? - litecoin90 - 05-07-2021

My controllers Code:

Code:
                            $this->Item_model->updateItemcoupon($data, $id);






My Modal Code:

Code:
public function updateItemcoupon($data, $id)
    {
        $this->db->where('Items', $id);
        $this->db->update('Coupon_codes', $data);
        return TRUE;
    }



RE: How to remove the first word From Mysql Table? - InsiteFX - 05-08-2021

Yoou also need to show the data array that your passing to it.


RE: How to remove the first word From Mysql Table? - litecoin90 - 05-08-2021

(05-08-2021, 02:30 AM)InsiteFX Wrote: Yoou also need to show the data array that your passing to it.


Code:
                $data = $itemId->coupon_codes;

coupon_codes Is Mysql Table which Containt Text Like This   Start JkLkLKLLk65 Flashsale2021  
Now i Want to Remove The First word Start From coupon_codes Table .. From Tell me How Can i do This Action??



RE: How to remove the first word From Mysql Table? - wdeda - 05-08-2021

Below, assuming you are using CI 4, the query needed to perform the action:
PHP Code:
$db $this->db;
$id '1';
$query $db->table('items')
->
select('Coupon_codes')
->
where('id'$id)
->
delete(); 



RE: How to remove the first word From Mysql Table? - litecoin90 - 05-08-2021

(05-08-2021, 07:11 AM)wdeda Wrote: Below, assuming you are using CI 4, the query needed to perform the action:
PHP Code:
$db $this->db;
$id '1';
$query $db->table('items')
->
select('Coupon_codes')
->
where('id'$id)
->
delete(); 


Hi, Can You tell me How to remove the first word From Mysql Table?
I Want To Update My Mysql Table and Want to remove The first word From My Mysql Table.. Table Contact Text ...


RE: How to remove the first word From Mysql Table? - nfaiz - 05-08-2021

Like this SQL?

Code:
UPDATE items SET
Coupon_codes = SUBSTRING(Coupon_codes, LOCATE(' ', Coupon_codes)+1)
--WHERE id = :id:



RE: How to remove the first word From Mysql Table? - litecoin90 - 05-08-2021

(05-08-2021, 09:29 AM)nfaiz Wrote: Like this SQL?

Code:
UPDATE items SET
Coupon_codes = SUBSTRING(Coupon_codes, LOCATE(' ', Coupon_codes)+1)
--WHERE id = :id:

Yes . But How Can i do This in codeigniter?


Here is My code 


Code:
public function updateItemcoupon($data, $id)
    {
        $this->db->where('Items', $id);
        $this->db->update('Coupon_codes', $data);
        return TRUE;
    }


What should i add ??


RE: How to remove the first word From Mysql Table? - wdeda - 05-08-2021

(05-08-2021, 09:28 AM)litecoin90 Wrote:
(05-08-2021, 07:11 AM)wdeda Wrote: Below, assuming you are using CI 4, the query needed to perform the action:
PHP Code:
$db $this->db;
$id '1';
$query $db->table('items')
->
select('Coupon_codes')
->
where('id'$id)
->
delete(); 


Hi, Can You tell me How to remove the first word From Mysql Table?
I Want To Update My Mysql Table and Want to remove The first word From My Mysql Table.. Table Contact Text ...

In the same way used in the example for the "items" table.
PHP Code:
$query $db->table('items'// in this line the table is informed, in this example, items;
->select('Coupon_codes'// here the row where the text to be deleted is located, in this example, Coupon_codes.