这是我的实际查询:
SELECT temp.id_company AS id_company
, temp.code_product AS id_product
, temp.date_product AS date_p
FROM (
SELECT *
FROM companies
INNER JOIN products
ON products.id_company_product = companies.id_company
WHERE module_key_company = "daL/RqzZcfqc."
) AS temp
WHERE temp.code_product = "app_12"
首先我得到companies.id_company where companies.module_key_company
匹配“dal.....”然后我检查我是否得到匹配products.code_product = "app_12"
并且products.id_company = companies.id_company
我在第一次测试后得到。
如果这两个条件都成立,我就会得到我想要的。但如果没有匹配的products.code_product
.
module_key
即使错误,我也无法找到仅通过测试才能获得 id_company的code_product
方法。
谢谢你的帮助。