Results 1 to 3 of 3
  1. #1
    Join Date
    Oct 2014
    Posts
    9

    Unanswered: take result of concat_ws query and save as new column

    Hi everyone! Not exactly a "noob" but I am in the process of learning. If I say something odd please correct me. I want how to do this right, not just get results

    using MariaDB
    Code:
    mysql  Ver 14.14 Distrib 5.5.39, for Linux (i686) using readline 5.1
    I am creating a database of software add-ons. The add-ons only work with specific version numbers. In my database I have four columns to handle this issue:
    MOD_V_MAJOR | MOD_V_MINOR | MOD_V_REV | MOD_V_BUILD

    each is stored as tinyint(4).

    Now, when I print out a query for people to check against, they see four rows of confusing data. However, I thought I might have fixed this issue with
    Code:
    select concat_ws('.',MOD_V_Major,MOD_V_Minor,MOD_V_Rev,MOD_V_Build) as MOD_V_HR from CMPL;
    . However, I have to type that out each time I use it. I want to automate this a bit so that I can use "MOD_V_HR" as if it was just another column on the table. Example:
    Code:
    select MOD_V_HR,MOD_Author,MOD_Name from CMPL where MOD_V_Major > 1

  2. #2
    Join Date
    Jan 2007
    Location
    UK
    Posts
    11,434
    Provided Answers: 10
    Create a view:
    Code:
    CREATE VIEW view_name
      AS
    SELECT concat_ws('.', MOD_V_Major, MOD_V_Minor, MOD_V_Rev, MOD_V_Build) as MOD_V_HR
         , MOD_V_Major
         , MOD_V_Minor
         , MOD_V_Rev
         , MOD_V_Build
         , MOD_Author
         , MOD_Name
    FROM   CMPL
    Then
    Code:
    SELECT MOD_V_HR
         , MOD_V_Major
         , MOD_V_Minor
         , MOD_V_Rev
         , MOD_V_Build
         , MOD_Author
         , MOD_Name
    FROM   view_name
    WHERE  MOD_V_Major > 1
    George
    Home | Blog

  3. #3
    Join Date
    Oct 2014
    Posts
    9
    Thank you. That worked and solved another issue I was working on.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •