I have two tables in one of them a seller saves a record for a product he is selling. and in another table buyers save what they need to buy.
I need to get a list of user ids (uid field) from buyers table which matches a specific product on sales table. this is what I have written:
select n.[uid] from needs n left join ads(getdate()) a on n.mid=a.mid and a.[year] between n.from_year and n.to_year and a.price between n.from_price and n.to_price and n.[uid]=a.[uid] and a.pid=n.pid Well I need to use a where clause to eliminate those records which doesn't match. as I think all of these conditions are defined with ON must be defined with a where clause. but joining needs at least one ON clause. may be I shouldn't join two tables? what can I do?
INNER JOINand see if that meets your requirements. In order words, delete the wordLEFTfrom your query.