这是我的SQL查询:
SELECT pvl.name_parametre_value_parametre_value_lang,
pv.id_parametre_value,
ic.id_combinaison,
ic.prix_combinaison,
ic.poid_combinaison,
ic.actif_combinaison,
ic.actif_genere,
pv.actif_value,
pipv.id_parametre_value AS pipv_id_parametre_value
FROM psimpserv_imp_combinaison_parametre_value_1 cpv
LEFT JOIN psimpserv_imp_combinaison_1 ic
ON ic.id_combinaison = cpv.id_combinaison
LEFT JOIN psimpserv_imp_parametre_value pv
ON pv.id_parametre_value = cpv.id_parametre_value
LEFT JOIN psimpserv_imp_parametre_value_lang pvl
ON pvl.id_parametre_value = pv.id_parametre_value
LEFT JOIN psimpserv_imp_parametre p
ON p.id_parametre = pv.id_parametre
LEFT JOIN psimpserv_imp_product_impression_parametre_value pipv
ON pipv.id_parametre_value = pv.id_parametre_value
AND pipv.id_product_impression = 6
WHERE p.id_nom_domaine = 1
AND pvl.id_lang_domaine = 3
AND ic.id_product_impression = 6
AND '250' LIKE (
Concat('%', pvl.name_parametre_value_parametre_value_lang, '_', pv.id_parametre, '%') )
-- AND '2' LIKE ( CONCAT('%',pvl.name_parametre_value_parametre_value_lang,'_',pv.id_parametre,'%') )
GROUP BY ic.id_combinaison,
cpv.id_parametre_value
ORDER BY ic.id_combinaison,
p.id_parametre
LIMIT 0, 32
MySQL返回空结果。
答案 0 :(得分:0)
试试这个
SELECT pvl.name_parametre_value_parametre_value_lang, pv.id_parametre_value, ic.id_combinaison, ic.prix_combinaison, ic.poid_combinaison, ic.actif_combinaison, ic.actif_genere, pv.actif_value, pipv.id_parametre_value AS pipv_id_parametre_value
FROM
psimpserv_imp_combinaison_parametre_value_1 cpv
LEFT JOIN psimpserv_imp_combinaison_1 ic
ON ic.id_combinaison = cpv.id_combinaison
LEFT JOIN psimpserv_imp_parametre_value pv
ON pv.id_parametre_value = cpv.id_parametre_value
LEFT JOIN psimpserv_imp_parametre_value_lang pvl
ON pvl.id_parametre_value = pv.id_parametre_value
LEFT JOIN psimpserv_imp_parametre p
ON p.id_parametre = pv.id_parametre
LEFT JOIN psimpserv_imp_product_impression_parametre_value pipv
ON pipv.id_parametre_value = pv.id_parametre_value
AND pipv.id_product_impression = 6
WHERE p.id_nom_domaine = 1
AND pvl.id_lang_domaine = 3
AND ic.id_product_impression = 6
AND '250' LIKE (
CONCAT(
'%', pvl.name_parametre_value_parametre_value_lang, '_', pv.id_parametre, '%'
)
)
AND '2' LIKE (
CONCAT(
'%', pvl.name_parametre_value_parametre_value_lang, '_', pv.id_parametre, '%'
)
)
GROUP BY ic.id_combinaison, cpv.id_parametre_value
ORDER BY ic.id_combinaison, p.id_parametre
LIMIT 0, 32
答案 1 :(得分:0)
有些事情对我来说是错误的:
所以这是格式化的查询
SELECT
pvl.name_parametre_value_parametre_value_lang,
pv.id_parametre_value,
ic.id_combinaison,
ic.prix_combinaison,
ic.poid_combinaison,
ic.actif_combinaison,
ic.actif_genere,
pv.actif_value,
pipv.id_parametre_value AS pipv_id_parametre_value
FROM
psimpserv_imp_combinaison_parametre_value_1 cpv
LEFT JOIN psimpserv_imp_combinaison_1 ic ON
ic.id_combinaison = cpv.id_combinaison
LEFT JOIN psimpserv_imp_parametre_value pv ON
pv.id_parametre_value = cpv.id_parametre_value
LEFT JOIN psimpserv_imp_parametre_value_lang pvl ON
pvl.id_parametre_value = pv.id_parametre_value
LEFT JOIN psimpserv_imp_parametre p ON
p.id_parametre = pv.id_parametre
LEFT JOIN psimpserv_imp_product_impression_parametre_value pipv ON
pipv.id_parametre_value = pv.id_parametre_value AND pipv.id_product_impression = 6
WHERE
p.id_nom_domaine = 1 AND pvl.id_lang_domaine = 3 AND ic.id_product_impression = 6 AND '250' LIKE(
CONCAT(
'%',
pvl.name_parametre_value_parametre_value_lang,
'_',
pv.id_parametre,
'%'
)
)
-- AND '2' LIKE ( CONCAT('%',pvl.name_parametre_value_parametre_value_lang,'_',pv.id_parametre,'%') )
GROUP BY
ic.id_combinaison,
cpv.id_parametre_value
ORDER BY
ic.id_combinaison,
p.id_parametre
LIMIT 0, 32
您需要在AND
之前检查查询中的--
所以这可能是固定的:
SELECT
pvl.name_parametre_value_parametre_value_lang,
pv.id_parametre_value,
ic.id_combinaison,
ic.prix_combinaison,
ic.poid_combinaison,
ic.actif_combinaison,
ic.actif_genere,
pv.actif_value,
pipv.id_parametre_value AS pipv_id_parametre_value
FROM
psimpserv_imp_combinaison_parametre_value_1 cpv
LEFT JOIN psimpserv_imp_combinaison_1 ic ON
ic.id_combinaison = cpv.id_combinaison
LEFT JOIN psimpserv_imp_parametre_value pv ON
pv.id_parametre_value = cpv.id_parametre_value
LEFT JOIN psimpserv_imp_parametre_value_lang pvl ON
pvl.id_parametre_value = pv.id_parametre_value
LEFT JOIN psimpserv_imp_parametre p ON
p.id_parametre = pv.id_parametre
LEFT JOIN psimpserv_imp_product_impression_parametre_value pipv ON
pipv.id_parametre_value = pv.id_parametre_value AND pipv.id_product_impression = 6
WHERE
p.id_nom_domaine = 1 AND pvl.id_lang_domaine = 3 AND ic.id_product_impression = 6 AND '250' LIKE(
CONCAT(
'%',
pvl.name_parametre_value_parametre_value_lang,
'_',
pv.id_parametre,
'%'
)
)
AND '2' LIKE ( CONCAT('%',pvl.name_parametre_value_parametre_value_lang,'_',pv.id_parametre,'%') )
GROUP BY
ic.id_combinaison,
cpv.id_parametre_value
ORDER BY
ic.id_combinaison,
p.id_parametre
LIMIT 0, 32