Forum Moderators: open

Message Too Old, No Replies

craftin mysql query

exclude results by checking in another table

         

SubCon

3:35 pm on Sep 24, 2009 (gmt 0)

10+ Year Member



Hello all, I need some help with this query.. The query is very long so I'm not posting it here unless it'll really be necessary. Basically it gets some rows from table products by some terms and Left JOINs other tables checking some stuff there. Now I need the following: There are dates when those products are reserved so I need to exclude those from the result based on provided date range something like
SELECT FROM #__properties_available_product'
.' WHERE id_product = ' .$prop_id
.' AND date BETWEEN "'.$start.'" AND "' .$end. '"'; But to exclude those from the result.

Thanks

rocknbil

4:28 pm on Sep 24, 2009 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



" .... and (tablename.date < "'.$start.'" AND tablename.date > "' .$end. '")'

SubCon

4:50 pm on Sep 24, 2009 (gmt 0)

10+ Year Member



don't think its the right way: the dates table has only unavailable dates if there are any. the table goes like this:
id_product - id's
dates - 1 per row so there may be 10 dates for the same product. What I need to do is to find those products that are unavailable at the provided date range and exclude them from the result.

SubCon

9:27 pm on Sep 24, 2009 (gmt 0)

10+ Year Member



ok got it, you have to use left outer join, some tricky syntax but its fine and working now.