I have a query for tyre repairs which returns a job number and the position of the tyre being repaired. The problem is that where there multiple tyre repairs on one job all show in the same field. The positions are N/S/R, O/S/R, N/S/F and O/S/F, and when there is more than 1 they are seperated by the pipe symbol, which I don't need. I want to see one row for each tyre position in the position field.
Here is some sample data:
JOBNO VARCHAR(10) NOT NULL PRIMARY KEY
,POSITION VARCHAR(23) NOT NULL
);
INSERT INTO tyrejobs(JOBNO,POSITION) VALUES ('00IP151117','N/S/F|N/S/R|O/S/F|O/S/R');
INSERT INTO tyrejobs(JOBNO,POSITION) VALUES ('00IP151241','O/S/R');
INSERT INTO tyrejobs(JOBNO,POSITION) VALUES ('00IP151408','N/S/R');
INSERT INTO tyrejobs(JOBNO,POSITION) VALUES ('00IP151565','N/S/F|N/S/R');
INSERT INTO tyrejobs(JOBNO,POSITION) VALUES ('00IP151800','O/S/F');
INSERT INTO tyrejobs(JOBNO,POSITION) VALUES ('00IP151817','O/S/R');
INSERT INTO tyrejobs(JOBNO,POSITION) VALUES ('00IP151869','O/S/F');
INSERT INTO tyrejobs(JOBNO,POSITION) VALUES ('00IP151870','N/S/R');
INSERT INTO tyrejobs(JOBNO,POSITION) VALUES ('00IP151884','N/S/R|O/S/F');
INSERT INTO tyrejobs(JOBNO,POSITION) VALUES ('00IP151886','N/S/F');
INSERT INTO tyrejobs(JOBNO,POSITION) VALUES ('00IP151891','N/S/R');
INSERT INTO tyrejobs(JOBNO,POSITION) VALUES ('00IP151899','N/S/F');
INSERT INTO tyrejobs(JOBNO,POSITION) VALUES ('00IP151908','N/S/F');
INSERT INTO tyrejobs(JOBNO,POSITION) VALUES ('00IP151929','N/S/F|O/S/F|O/S/R'); ````
This is a sample of the output I need:
````+------------+----------+
| JOBNO | POSITION |
+------------+----------+
| 00IP151117 | N/S/F |
| 00IP151117 | N/S/R |
| 00IP151117 | O/S/F |
| 00IP151117 | O/S/R |
| 00IP151241 | O/S/R |
| 00IP151408 | N/S/R |
| 00IP151565 | N/S/F |
| 00IP151565 | N/S/R |
| 00IP151800 | O/S/F |
| 00IP151817 | O/S/R |
| 00IP151869 | O/S/F |
| 00IP151870 | N/S/R |
| 00IP151884 | N/S/R |
| 00IP151884 | O/S/F |
+------------+----------+ ````
What is the best way to acheive this?
Many thanks
Martyn