-1

i was wondering how would i make a sql code that makes one column merge into one line

please see attached photo of an example table of before and after of what i need

can this be done

any help will be appreciated

thanks HERE IS THE IMAGE OF WHAT I NEED

  • Can you put the data of the image in text format? Do you want the first column (Title) to keep its old length? – bert wassink Mar 26 '22 at 19:07
  • Does this answer your question? [How to concatenate text from multiple rows into a single text string](https://stackoverflow.com/questions/194852/how-to-concatenate-text-from-multiple-rows-into-a-single-text-string-in-sql-serv) – Stu Mar 26 '22 at 20:00
  • Rather than images, use formatted text in your question. – Steffan Westcott Mar 27 '22 at 12:35

1 Answers1

0

Use GROUP_CONCAT() in mySQL or mariaDB, STRING_AGG() in SQL server, Oracle or Postgres.
Here is an example in mySQL:

create table examples(
id int,
example varchar(10));
insert into examples values
(1,'Example 1'),
(2,'Example 2'),
(3,'Example 3'),
(4,'Example 4');
select group_concat(example) Examples
from examples;
| Examples                                |
| :-------------------------------------- |
| Example 1,Example 2,Example 3,Example 4 |

db<>fiddle here

  • how would i then put this to result into a column as the result shows but i wanted the result to go into a coulmn – MK456789 Apr 02 '22 at 09:57
  • What are all the values in the row of title 1? I could use a sub-query to join the rows and only show them for 1 but if my logic is not what you want it will not be useful to you. –  Apr 02 '22 at 10:25