If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > MySQL > Managing appointment conflicts

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 11-23-06, 10:11
gtk gtk is offline
Registered User
 
Join Date: Oct 2004
Location: Paris, FRANCE
Posts: 132
Post Managing appointment conflicts

Hello,

I'm trying to manage appointment conflicts in a calendar application.
Here is the table kind of format that I use with sample data:
Code:
+-----------------+
| calendar_events |
+------------+-------+-------+---------------------+
| date       | start | end   | location            |
+------------+-------+-------+---------------------+
| 2006-11-22 | 10:30 | 12:00 | Paris Montparnasse  |
| 2006-11-22 | 14:00 | 15:00 | Paris StLazarre     |
+------------+-------+-------+---------------------+
The user give start and end times (let's say given_start and given_end)
The aim is to find if there is any conflict.
I made this query:
Code:
SELECT
	start AS "start",
	end AS "end",
	location AS "location"
FROM
	calendar_events
WHERE
	date = "2006-11-22"
	AND (
		(
			[$given_start] > start
			AND [$given_start] < end
		)
		OR
		(
			[$given_end] > start
			AND [$given_end] < end
		)
		OR
		(
			[$given_start] < start
			AND [$given_end] > end
		)
		OR [$given_start] = tup.start_time
		OR [$given_end] = tup.end_time
	)
ORDER BY
	tup.start_time
Isn't it an easiest way ?
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On