'SQL Conditional query for comparing tables with every matching value
I have 2 separate tables that I am comparing. I would like to join them, but only if they both have a complete set of matching rows. For example:
Examples of 2 joined tables with matching data
in this example you can see that the data is matching perfectly, they both have matching id's and matching variables. However, I would like to implement a check so that if the variables do not match up at any point, say for example in one table it didn't have "0.4" for any reason, then that entire piece of equipment would be left out from the resulting table all together
SELECT *
FROM Equipment
INNER JOIN
(SELECT
variable
FROM
VariablesTable
WHERE
variable >= @Min_Var AND variable <= @Max_Var) AS Var
ON EquipmentVariable = Var.variable
Here is a snippet of my code so far as an example, any suggestions would be much appreciated
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
