How to write inner join with database explorer

Creator26
Member | 3
+
0
-

I try to learn work with database explorer, but I am lost when I try write this. Have you any idea how to write this code?

I don't have foreign keys in database.

$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);

Last edited by Creator26 (2018-08-06 22:07)