Home > Software engineering >  How to deal with sequence when concatenating SQL
How to deal with sequence when concatenating SQL

Time:07-25

I'm dealing with large chunks of data (~50K rows)

I'm concatenating 2 columns for querying, and I want to make so that order of the two concatenated columns do not matter

I.E.

Raw data:
item1 | item2 
cat   | dog
dog   | cat
Query result :
items
catdog
catdog

CodePudding user response:

Some built in functions will help

SELECT CONCAT( LEAST(item1, item2), GREATEST(item1, item2) )

I guess that is what you want.

  • Related