Jump to content

join queries


searls03

Recommended Posts

I am not very knowledgeable on join queries but this is what i have:

$sql=mysql_query("select cat.id, cat.subcategory, cat.category, prod.product, prod.price, prod.id, prod.category, prod.subcategory from categories cat
left join products  prod
on cat.category = prod.category
where prod.prodcut='$prodcut' and prod.category='$category' ");

 

What I need is for a query to run through the database table"categories" picking out all the categories, then based on the category, it picks from "products" with the same category in the column "category".  here is the problem though, I need all the results to display, so there are like 10 categories, I need to see all those categories, then there are multiple products for each category, and I would like all those to display.  anyhelp here?  Am i even remotely close?

Link to comment
https://forums.phpfreaks.com/topic/264382-join-queries/
Share on other sites

I am saying that I would like to use PHP to query the database, I don't want to do it from PHPmyAdmin/Mysql.

so a query like this:

// Query member data from the database and ready it for display
$sql = mysql_query("SELECT * FROM cart where cart_id = '".$_SESSION['cart_id']."' && academy= '$academy' && product123 !=''");
while($row = mysql_fetch_array($sql)){
$product = $row["product123"];
$price1 = $row["price"];
$id = $row["product_id"];
$qty = $row["quantity"];

Link to comment
https://forums.phpfreaks.com/topic/264382-join-queries/#findComment-1354844
Share on other sites

  • 2 weeks later...

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.