How to make a selection from Mysql according to the matching condition with one of the listed values?

For example, there is a base of machinery. The base is already done by some skilled programmer.

In one of the columns a comma separated list of machine parts: bumper, wheels, glass, exhaust pipe, etc.
Each car has their own individual set.

Machine 1: bumper, wheels, glass
Machine 2: wipers, wheels, washer
Machine 3: exhaust pipe, bumper, wheel
Machine 4: the starter, glass, wheel, pedals, gearbox
Machine 5: bumper

Now need help with a Mysql query to find cars that have bumper or wheel.
The request showed 1, 2, 3 and 5 of the machine.

Can't find the solution or come up with..
September 26th 19 at 07:12
2 answers
September 26th 19 at 07:14
The first thing that comes to mind is something like SELECT * FROM cars WHERE options LIKE %bumper% or options LIKE %wheel%
This request to work will be very inefficient, however, the database scheme are flawed. - Melyssa commented on September 26th 19 at 07:17
it is unlikely that the author there is a high load. If you make a full text index - normally it will work. But of course the correct database structure to change, Yes. - Jordon_Hickle91 commented on September 26th 19 at 07:20
September 26th 19 at 07:16
I would have 2 tables added - "view parts" and "spare car", and built them in a non-relational column. And then search and indexes - all inclusive.

PS I so understood, it does not base itself machines, and the base of what was left from cars :D
I agree, but in terms of the problem says that the field already exists, you need to find. It is not known where in the code are appeals to these fields. Though certainly at desire it is possible to redo everything. - Melyssa commented on September 26th 19 at 07:19
Well, if the condition is not to touch the database schema, then Your only option (or similar), but if there are many records, the query will be very slow. - Jordon_Hickle91 commented on September 26th 19 at 07:22
I absolutely agree with You - weldon44 commented on September 26th 19 at 07:25
However the REST of the code and not to touch. This table does not change, to make a trigger to update it, and create the appropriate entry in the table "parts cars", and in the required in this problem the query to use new table. I would do so, if there are conditions 1) maximum compatibility with existing code and 2) performance. - Melyssa commented on September 26th 19 at 07:28
Thank you! Think so too. Probably will have to make changes to an existing design base. - weldon44 commented on September 26th 19 at 07:31

Find more questions by tags MySQL