Current location: Hot Scripts Forums » Programming Languages » PHP » SQL Help


SQL Help

Reply
  #1 (permalink)  
Old 06-03-04, 05:50 PM
danielf danielf is offline
New Member
 
Join Date: Jun 2004
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
SQL Help

I need help with an SQL statement. I would really appreciate it if someone could help me.

I have 3 tables.

users
- userid, int pk (auto)
- username, varchar username (ex. foobar)

events
- eventid, int pk (auto)
- description event description (ex. BIG PARTY!)

confirm
- confirmid, int pk (auto)
- eventid, int fk
- userid, int fk
- confirm, int 0 if user is not attending, 1 if user is attending, 2 if user is not sure
- timestamp (auto)

System works the following way.

A user creates a new event (party, meeting, etc) [table events].
Users confirm if they will attend, will not or isnt sure [table confirm].
Users can change their mind.
So if a user confirms he will attend and then changes his mind, table confirm will have 2 entries with his userid. One entry

will have confirm=1 and the other will have confirm=0 or confirm=2.

I need and sql statement that will return me the following information for a giver userid:

events.eventid, events.description, confirm

"confirm" column should be:
- NULL if no rows are found in table confirm with the users given userid
- 0 if last entry for that user was a 0
- 1 if last entry for that user was a 1
- 1 if last entry for that user was a 2

An example would be

events.eventid events.description confirm
1 BIG PARTY! NULL
2 Staff Meeting 0
3 Paintball 1
4 Sking 1
5 Poker 2

User's last confirmation is that he is going Sking and playing Paintball. He will not attend the Meeting.
He has not decided if he is going to the party or not. He has not decided if he is going to play poker.
Reply With Quote
Reply

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
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

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
SQL infinite loop problem with VB application Syed Visual Basic 2 05-07-04 10:19 AM
Help with ASP & FORMS blessedrub ASP 0 01-23-04 10:22 AM
union sql msrnivas ASP.NET 1 10-21-03 03:36 PM
ASP Calendar..HELP...pls jimthepict ASP 1 07-31-03 05:01 PM
change my field in this example sal21 ASP 3 07-14-03 02:49 AM


All times are GMT -5. The time now is 10:37 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.