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 9040133
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T09:54:34+00:00 2026-06-16T09:54:34+00:00

I have table as below create table myTable (id int, col1 varchar(20), col2 varchar(20),

  • 0

I have table as below

create table myTable (id int, 
                  col1 varchar(20),
                  col2 varchar(20),
                  col3 varchar(20),
                  col4 varchar(20),
                  col5 varchar(20),
                  col6 varchar(20),
                  col7 varchar(20),
                  col8 varchar(20),
                  col9 varchar(20)
                 );

And have data as

insert into myTable values
(1, 'col1','col2','col3','col4','col5','col6','col7','col8','col9');

What I want is output as

id +  AllInOne
++++++++++++++++++++++++++++++++++++++++++++++++++
 1 + col1-col2-col3-col4-col5-col6-col7-col8-col9
++++++++++++++++++++++++++++++++++++++++++++++++++

Any idea how to get this done with smallest query? I know I could do above with use of CONCATENATE. But I would need is some other way. Maybe some pre-defined MySQL function?

Data at sqlfiddle

  • 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-16T09:54:35+00:00Added an answer on June 16, 2026 at 9:54 am

    Use CONCAT_WS, that concatenates strings (skipping null ones) with a separator:

    SELECT id, CONCAT_WS('-', col1, col2, col3, col4, col5, col6, col7, col8, col9)
    FROM your_table
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created table and inserted values as below. create table mytable (id INT,
e.g. If I have a table like below:- create table Categories(CategoryId int primary key,
I have a history table like below CREATE TABLE [dbo].[t_PettyCash_History] ( [TableName] [varchar] (500)
I have an SQL table defined as below: CREATE TABLE [TestComposite] ( ID int,
I have mysql database structure like below: CREATE TABLE test ( id int(11) NOT
I have created one table using the below command: create table Table1( Id int
Below is how my table is create table tab (id INT, fullname varchar(100)); Data
I have a table trigger like below: CREATE OR REPLACE TRIGGER PAT_BUR_DOB_TRG BEFORE UPDATE
i have a column family use counter as create table command below: (KEY i
I have two MySql tables as shown below with the data shown: CREATE TABLE

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.