I'm trying to build a SQL query that will show me all the products that have products.description IS NULL
but also have a corresponding description in the descriptions table. So code is always a substring of info.
The products.code
is a substring of descriptions.info
, so I'm not sure how to pull this.
products
id | code | description
--------------------------
1 12345-1 NULL
descriptions
id | info
---------------------------
1 12345-1_Hammer
Best Answer
You need t o compare
product.info
withdescriptions.info
. If the needed condition is for one to be a substring of the other, it can be done withLIKE
.Since there may be more than one descriptions matching (having as substring) a product code, we should use an
EXISTS
subquery: