Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8250787
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T00:00:59+00:00 2026-06-08T00:00:59+00:00

I have a trigger containing this: SET v1 = CONCAT_WS(‘,’,NEW.ID, NEW.Name, NEW.Type, NEW.Value); Can

  • 0

I have a trigger containing this:

SET v1 = CONCAT_WS(',',NEW.ID, NEW.Name, NEW.Type, NEW.Value);

Can this be simplified into something like this to include the entire new row?:

SET v1 = CONCAT_WS(',',NEW.*);

(I’ve tried variations of the above however they causes syntax errors)

Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-08T00:01:03+00:00Added an answer on June 8, 2026 at 12:01 am

    No, there’s no easy way to do this. You have to reference each column.

    The only real workaround is to use the table metadata to help you generate the statement you want, and then include that statement in your procedure.

    You wouldn’t want to do this dynamically in the TRIGGER, even if it were possible.

    SELECT CONCAT('NEW.`',GROUP_CONCAT(c.column_name 
           ORDER BY ORDINAL_POSITION SEPARATOR '`,NEW.`'),'`')
      FROM information_schema.columns 
     WHERE table_schema = DATABASE() 
       AND table_name = 'mytable'
    

    That should get you a string that looks like:

    NEW.`ID`,NEW.`Name`,NEW.`Type`,NEW.`Value`
    

    And you can paste that into your trigger body. (Of course you could extend the CONCAT to generate the whole line.)

    The downside is that when new columns are added to the table, those won’t get automatically included; that will require a change in the trigger. If a column gets dropped or renamed, your trigger will start throwing exceptions; again requiring a fix to the trigger.


    UPDATE

    Q:How can I convert this string into a MySQL query?

    @query = "CONCAT_WS(',','CCC','64',NEW.Record,NEW.ID,NEW.Name,NEW.User_ID,NEW.State_Record,NEW.Hash);"
    

    I wouldn’t convert that to a query. I would just use that as static line of code (with no double quotes) in the body of your trigger, just like the original statement you had in your TRIGGER.

    SET v1 = CONCAT_WS(',','CCC','64',NEW.Record,NEW.ID,NEW.Name,NEW.User_ID,NEW.State_Record,NEW.Hash);
    

    (It wasn’t clear what you intended to do with that string.)

    If you are trying to create a SELECT statement, you could try removing that semicolon from the end of the string, and prepending a SELECT keyword on it. But I don’t think the NEW. references to the column values of the current row will be recognized in that context. That might happen, but you’d need to test.

    If I needed to do something like that, I would do it using user variables,

    SET @new_id = NEW.ID;
    SET @new_name = NEW.Name;
    
    SELECT @new_id, @new_name 
    

    It’s not at all clear to me what you are going to do with the result set returned by a query like. If you are attempting to audit changes to the table, the normative pattern is to run an INSERT of the column values into an changelog table,

    INSERT INTO mytable_changelog (ID, Name) VALUES (NEW.ID, NEW.Name);
    

    It really depends on what you are trying to accomplish.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this trigger which works functionally (as far as I can tell by
I have a div, containing text and a few links. I want to trigger
I have a trigger that looks something like this: create or replace TRIGGER cluster_check
I have below trigger ALTER TRIGGER [dbo].[DeleteUserData] ON [dbo].[site_users] AFTER DELETE AS BEGIN SET
I have a table containing hierarchical data. There are currently ~8 levels in this
I have to integrate a Java applet into a simple asp.net 2.0 control. This
I have this table containing 3 radio buttons, I want to find out whether
I have a textbox containing a decimal value on my interface that I want
I have a trigger that check data before insert to another table IF NOT
I have a trigger that stores changes made in a separate table when a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.