Alpinestar22 Alpinestar22 - 1 year ago 120
PHP Question

MySQL join returning redundant data

I am building an auction website. Right now, I am building the item description page, that has item details, as well as current bid history. My bids table has a FK of Item_id.

My current query looks something like this:

SELECT bids.Item_id, bids.User_email, bids.Bid_amount, products.*
FROM bids
INNER JOIN products
ON bids.Item_id=products.Item_id;

This returns all of the bid information I need - but also returns the item description for every bid row. I only need the product information once. Is it best to just use two queries on this?

Any help is appreciated

Answer Source

If you need the bids data separately from the products data, then you should use two queries.

One query cannot really be arrange to return different columns for different rows.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download