0

Version: MySQL 8.0

Fiddle : https://www.db-fiddle.com/f/dZceV3UaHuo9KDQjhWqjP9/10

I have a table of vehicles and a table of specifications. I need to query for which specifications are missing for a given vehicle.

Example Data

============================================
| tb_specificationtypes                    |
============================================
| SpecificationTypeID | SpecificationType  |
|-------------------------------------------
|           1         | Color              |
|           2         | Shape              |
|           3         | Speed              |
|           4         | Voltage            |
============================================


==========================================================================
| tb_specifications                                                      |
==========================================================================
| SpecificationTypeParent | SpecificationValue | SpecificationAssignment |
|-------------------------------------------------------------------------
|           1             | White              | CAR000                  |
|           2             | Rounded            | CAR000                  |
|           3             | Fast               | CAR000                  |
|           1             | Red                | CAR001                  |
|           4             | 12V                | CAR001                  |
==========================================================================

What I want to determine is, say, which specifications am I missing for a given vehicle.

The result for CAR000 should be:

Voltage

The result for CAR001 should be:

Shape
Speed

I have a SQL Fiddle where I have prepopulated the tables with a little data and have a basic join. I have tried all types of joins, and have Googled every possible thing I can think of to describe the problem, but I'm out of ideas.

Beems
  • 781
  • 2
  • 12
  • 32

0 Answers0