I’m looking for a way to do this in SingleStore:
I have a column with coma separated string that I need to split to different rows and the join to the table as a new column
sql server script:
SELECT id,
product_ids,
value new_col
FROM platform.manual_rule
CROSS APPLY STRING_SPLIT(product_ids, ',')
thank you,
I tried but I got this error massage (I also try with string split()) :
ERROR 1054 ER_BAD_FIELD_ERROR: Unknown column ‘value’ in ‘field list’
We also now support explicit LATERAL JOIN syntax that works for this and other kinds of queries. E.g.
singlestore> select * from r;
+------+------+
| id | s |
+------+------+
| 2 | c,d |
| 1 | a,b |
+------+------+
2 rows in set (0.03 sec)
singlestore> select * from r lateral join table(split(s,","));
+------+------+-----------+
| id | s | table_col |
+------+------+-----------+
| 2 | c,d | c |
| 2 | c,d | d |
| 1 | a,b | a |
| 1 | a,b | b |
+------+------+-----------+
You can also use a correlated subquery on the right of LATERAL. We still do an implicit lateral join when you used the TABLE function after a comma in the FROM list.