mysql - Multiple table query with wrong rows -
i want query 2 tables resulting query has more rows should be.
my statement is:
select * deal d, item d.dealstate = 'accepted' , ((d.owner = 'username1') or (d.itemid = i.itemid , i.owner = 'username1')) , d.deadline < now()
with statement want user's active deals. deal table has owner (the requester), dealid, itemid, creationdate, dealstate, deadline, explanation
, item table has owner (the owner of item), itemid, itemname, description
.
the problem want query 1 result. because 'username1' has 1 deal. query 10 rows, each of items matched deal. thought using "join" if user not owner of item, item table won't used. then, should do?
i hope i'm clear enough.
your query doesn't join correctly 2 tables because d.itemid = i.itemid
isn't true in wrote. try
select * deal d, item d.dealstate = 'accepted' , d.itemid = i.itemid , ((d.owner = 'username1') or ( i.owner = 'username1')) , d.deadline < now();
Comments
Post a Comment