I have a table in SQL. I have a column named CarMakes, it has the following contents:
Mercedes, BMW
Range Rover
Mazda, Toyota, Honda
I want to know how to return a number of CarMakes in each row.
Returned value should be 2, 1 and 3 respectively.
This is a MySQL-based answer, so it may be inappropriate for your case if you’re using something else. This assumes the values are comma-separated and in the same column (quite an assumption 🙂 ):
I’m sure this will run into issues somewhere, but it may work if your situation doesn’t contain random commas. You can see the SQLFiddle here.