I'd like, for each commercial, identified here by a code, to get the number of bills (in French: facture) being associated with him.
For example, here, with this part of the database, I'd like to have something like that: R08: 22; R087: 19; R11 : 3; R00 : 3; R062: 1; R026: 1;
A commercial code starts with a 'R' followed by a few digits and if the bill is associated with more than one commercial, a '|' separates the codes. By the way, most of the bills are associated with only one commercial.
My problem is to do that only with SQL. if it's too complicated, I'll do it with PHP.
I hope my question is understandable and that you'll know how to help me.
An other example of data:
R015 15040205
R012 14250123
R012|R038 14250123
R015|R012 14250123
R005 14250123
I'd like a query that returns:
R005 1
R038 1
R015 2
R012 3
actually, I would like a query that counts the number of occurrences of each code. The second data doesn't matter