The data not going on the next row in mysql

The data not going on the next row in mysql
0.0 0

#1

Hello guys,

I have a query:
SELECT
DISTINCT
SUBSTRING_INDEX(SUBSTRING_INDEX(t.remarks, ‘,’, n.n), ‘,’, -1) remarks,
rtv_spare_parts_repair_header.no
FROM rtv_spare_parts_repair_header
join rtv_spare_parts_repair_detail t on rtv_spare_parts_repair_header.id = t.rtv_spare_parts_repair_id
JOIN
(
SELECT a.N + b.N * 10 + 1 n
FROM
(SELECT 0 AS N UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) a
,(SELECT 0 AS N UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) b
ORDER BY n
) n
WHERE rtv_spare_parts_repair_header.no ='RTVRS00026’
this is the result:

|no |remarks
|12 |broken glass
|12 |broken cap
|

this is working when I have a left join statement this is the left join with my items table:

SELECT
DISTINCT
SUBSTRING_INDEX(SUBSTRING_INDEX(t.remarks, ‘,’, n.n), ‘,’, -1) remarks,
rtv_spare_parts_repair_header.no,
items.item_description
FROM rtv_spare_parts_repair_header
join rtv_spare_parts_repair_detail t on rtv_spare_parts_repair_header.id = t.rtv_spare_parts_repair_id
join items on items.id = t.item_id
JOIN
(
SELECT a.N + b.N * 10 + 1 n
FROM
(SELECT 0 AS N UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) a
,(SELECT 0 AS N UNION ALL SELECT 1 UNION ALL SELECT 2 UNION ALL SELECT 3 UNION ALL SELECT 4 UNION ALL SELECT 5 UNION ALL SELECT 6 UNION ALL SELECT 7 UNION ALL SELECT 8 UNION ALL SELECT 9) b
ORDER BY n
) n
WHERE rtv_spare_parts_repair_header.no =‘RTVRS00026’

the result is this:

| items| no | remarks
webbb 12 broken cap
ddddd 13 null
fffffffff 14 null
webbb 12 broken motor
webbb 12 broken stuff

is there something wrong in my code?
can you check it for me?

thanks


#2

where is the answer?