Inner join – prepis do database explorer

Creator26
Člen | 3
+
0
-

Ahojte. V php mam tento kus kodu, ktory by som chcel prepisat do database exploreru. Zatial som strateny a neviem ako na to.

V databaze nemame cudzie kluce zadefinovane.

$query = "SELECT DISTINCT mb_variant.id_product as id_product, mb_product.url_sk, mb_product.title_sk, mb_variant.id, mb_variant.price, mb_variant.price_old, mb_variant.stock1 FROM mb_product INNER JOIN mb_product_category ON mb_product.id = mb_product_category.id_product INNER JOIN mb_variant ON mb_product.product_number = mb_variant.product_number WHERE mb_product_category.id_category IN ($categories) AND price > 0 ORDER BY mb_variant.stock1 DESC";

$stmt = $this->db->query($query);
$countProducts = $stmt->num_rows;
$products =  $stmt->fetch_all(MYSQLI_ASSOC);