Forum Moderators: open

Message Too Old, No Replies

Badly Formed MySQL Query

results, but not as we would expect

         

delboy1978uk

4:46 pm on May 22, 2007 (gmt 0)

10+ Year Member



this query here is wrong, somehow
SELECT a.quantity, a.delivered, p.productname, z.quantity as deld , z.tf
FROM actualorderdetails AS a, products AS p, delnotes AS d, deldetails AS z
WHERE
d.delnoteid = 2
AND a.orderid = d.orderid
AND a.productid = p.productid
AND z.delnoteid = d.delnoteid

i expect 4 lines to be returned
but instead i get 16, with 4 of each row.

Why?

phranque

6:33 am on May 23, 2007 (gmt 0)

WebmasterWorld Administrator 10+ Year Member Top Contributors Of The Month



just a wild guess but i would try this and see what happens:
SELECT a.quantity, a.delivered, p.productname, z.quantity as deld , z.tf
FROM actualorderdetails AS a, products AS p, delnotes AS d, deldetails AS z
WHERE
d.delnoteid = 2
AND a.orderid = d.orderid
AND a.productid = p.productid
AND z.delnoteid = 2