SQL - User input in query

前端 未结 3 1746
面向向阳花
面向向阳花 2021-01-06 00:13

I have this. \"Detail all films shown by the club between any two given dates, inputted by the user. For example a club member must be able to input a start date and an end

3条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-06 00:33

    @Kyle93 - Looking at your WHERE Clause:

    WHERE sdate = '&userstart' AND fdate = '&userend'

    This will only get you Films that had a sdate(Start Date?) equal to the date value entered. You might want to use Greater than, Less Than operators....

    Such as:

    WHERE sdate <= '&userend' AND fdate >= '&userstart'

    (Note comparing sdate to UserEnd Date to make sure Film Showing started EARLIER than the UserEnd Date...etc)

    This way - when a show starts OR ends within the date range - it will be selected.

提交回复
热议问题