Results 1 to 4 of 4

Thread: Problem with Query

  1. #1
    Join Date
    Feb 2009

    Problem with Query

    I have a table 'event' as follows
    login primary key,
    entrytime primarykey,
    foreign key(pastevent_login, pastevent_entrytime) references event(login,entrytime)
    if the event is previously arranged then past event login and entry time is stored which is from a same table,
    now when any event is displayed i want to display all past events associated with it as well as if any past event is displayed i want to display all its past as well as its future events , i want to achieve this if possible with single query please help..
    i am using mysql 5.x

  2. #2
    Join Date
    Feb 2009
    is it impossible???
    if it is, i have to write two php while loops for getting past as well as future events
    anybody please help

  3. #3
    Join Date
    Aug 2005
    The Garden State
    to be honest, you can't, with the way your table is structured. maybe if you had some way of knowing what user an event was associated with, but not in this structure. you'll have to repeatedly query for each key you find.
    Acceptable Use | SQL Forum FAQ | celery is tasteless | twitter

    celery is tasteless - currently needing some UI time

  4. #4
    Join Date
    Feb 2009
    Thanks for reply, now i have written while loops to achive the output
    I have another problem with the same table now when user organises a event he has the option reference that event to past event he has arranged, now when he enters the event title he gets list of events that he organised in past say for example he has organsed event1, second time he organised event2 giving the reference of event1 that he organised before, now when third time he organises the event when he enters the title i want only event2 to be displayed to him and not event1, because it will result in formation of tree structure which increase programming overhead, is it possible to form a single query to achive this, right now i have achived this with php,
    i also want to know what is the best structure for table when back referencing in the same table is required
    Last edited by spsarolkar; 03-15-2009 at 05:56 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
HTML5 Development Center