0

I have this database ("statement") where each word of a sentence is in a different row

SENTENCE |  SEQUENCE |  TEXT
    A   |   1       |   MY  
    A   |   2       |   NAME
    A   |   3       |   IS
    A   |   99      |   CARL
    B   |   1       |   MY  
    B   |   2       |   NAME
    B   |   3       |   IS
    B   |   99      |   JUSTINE

I would like to do a select where the result is the complete sentence, like:

 SENTENCE | TEXT
    A   |   MY  NAME IS CARL
    B   |   MY  NAME IS JUSTINE

since I cannot create a new table, I would like to put the command in the select just to have a new column. In each sentence the words are sorted in the column "sequence" and 99 is always the last word of the sentence.

I've tried adapting this solution but it didn't work.

Thank you very much

Turi

1
  • The solution you refer to is SQL-Server. MySQL has a whole other SQL syntax Commented Sep 7, 2017 at 10:26

1 Answer 1

1
select sentence, group_concat(text order by sequence separator ' ')
from your_table
group by sentence
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.