Answer the question
In order to leave comments, you need to log in
How to create a SQL query in Laravel in Query Builder?
SELECT
f.facet_id,
f.value,
MIN(f.value_num) min_value_num,
MAX(f.value_num) max_value_num,
COUNT(DISTINCT f.product_id) AS cnt
FROM catalog_index f
INNER JOIN (
SELECT
cp.id
FROM catalog_products cp
INNER JOIN catalog_index cf ON cf.product_id = cp.id
WHERE 1 = 1
AND cp.section_id = 440
AND cf.facet_id = 7718
AND cf.value IN (285)
) p ON p.id = f.product_id
WHERE f.section_id = 440
GROUP BY f.facet_id, f.value
$connection = Yii::$app->getDb();
$command = $connection->createCommand('SELECT * FROM users');
$result = $command->queryAll();
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question