check availability of a room with SQL

后端 未结 2 929
予麋鹿
予麋鹿 2021-01-25 04:55

I want to check if a certain room is available between a start and end date. I am doing this with a webservice function. This function gives back a list with all the reservation

相关标签:
2条回答
  • 2021-01-25 05:08

    AND has higher precedence than OR.

    Change the last line to:

    AND (res.DATUM_BEGIN >= @DATUM_EINDE OR res.DATUM_EINDE <= @DATUM_BEGIN)
    
    0 讨论(0)
  • 2021-01-25 05:24
      SELECT * FROM ARTICLES_RESERVERING res
      INNER JOIN ARTICLES_ZAAL roo ON res.ZAALID = roo.ID 
      WHERE roo.ID = @ZAALID
      AND  @DATUM_EINDE between res.DATUM_BEGIN and res.DATUM_EINDE
    

    I will rather use this query as using OR is generally expensive.

    0 讨论(0)
提交回复
热议问题