Welcome Guest, Not a member yet? Register   Sign In
How to remove the first word From Mysql Table?
#1

(This post was last modified: 05-07-2021, 06:41 AM by litecoin90.)

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?
Reply
#2

@litecoin90,

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

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;
    }
Reply
#4

Yoou also need to show the data array that your passing to it.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )
Reply
#5

(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??
Reply
#6

(This post was last modified: 05-08-2021, 07:22 AM by wdeda.)

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(); 
Reply
#7

(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 ...
Reply
#8

(This post was last modified: 05-08-2021, 09:30 AM by nfaiz.)

Like this SQL?

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

(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 ??
Reply
#10

(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. 
Reply




Theme © iAndrew 2016 - Forum software by © MyBB