[pgsql-jp: 25989] Re: 時間帯検索の重複チェック

Hiroshi Ishiura issy777 @ entrance-e.com
2002年 5月 16日 (木) 17:35:48 JST


石浦です。

> はじめまして。K2です。
> 
> On Thu, 16 May 2002 16:20:55 +0900
> Hiroshi Ishiura <issy777 @ entrance-e.com> wrote:
> 
> > 施設予約スケジュールのようなもの作っており、
> > 施設予約時間の重複チェックでいいSQL文が思いつきません。
> > 
> > 例えばreserveテーブルに以下のデータが入っていた場合
> > date	   |start_time|end_time
> > -----------------------
> > 2002-05-16 | 10:00:00  |13:00:00
> > 
> > そしてフォームより次の入力がされた場合
> > 2002-05-16 | 10:30:00  |12:00:00	A
> > 2002-05-16 | 13:00:00  |15:00:00	B
> > 2002-05-16 | 12:00:00  |14:00:00	C
> > 2002-05-16 | 09:30:00  |11:00:00	D
> > 
> > 現状
> > select * from reserve where date='$s_date' and start_time <= '$datetime'
> > and end_time >='$datetime'
> 
> いまいち $s_date とか $datetime が何を表しているのかよく分からない

すいません、変数をかきまちがえてしまいました。
$start_time を開始時刻、 $end_time を終了時刻
select * from reserve where date='$date' and start_time <= '$start_time'
 and end_time >='$end_time'

> ので外しているかもしれませんが、以下のような感じで如何でしょう?
> $s_time を開始時刻、 $e_time を終了時刻とします。
> 
> select * from reserve where date='$s_date' and end_time > '$s_time' and 
> '$e_time' > start_time;
> 
> でも、その前に start_time と end_time を timestamp 型にした方がいい
> と思います。
> 上の SQL でも日付がまたがるような予約についてはダメですし。
> 
> 
>  ---
> K2
> Email: koumei2 @ 104.net
> URL: http://koumei2.flets.cds.ne.jp:2080/
> 

-- 
Hiroshi Ishiura <issy777 @ entrance-e.com>





pgsql-jp メーリングリストの案内