Problem with Query

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sweatha
    New Member
    • Mar 2008
    • 44

    Problem with Query

    Hello Friends

    Here I have created 3 tables. They are

    Table Name: TheatreMaster
    -----------------------------------------------------------------------------------------------------
    tid tname showtime address phone mobile email
    -----------------------------------------------------------------------------------------------------




    --------------------------------------------------------------------------------------------------------

    Table Name: MovieMaster
    --------------------------------------------------------------------------------------------------------
    mid moviename actors director producer
    --------------------------------------------------------------------------------------------------------



    --------------------------------------------------------------------------------------------------------

    Table Name: ShowDetails
    ----------------------------------------------------------------------------------------------------------
    sid date tid mid showtime tickettypes status
    ----------------------------------------------------------------------------------------------------------




    -----------------------------------------------------------------------------------------------------------

    The dilemma is I want to select the tname (Theatre name) from "TheatreMas ter" depending on the moviename on "MovieMaste r" via table "ShowDetail s".

    i.e if I have 2 dropdown list boxes & in the 1st dropdownlistbox (which is populated with the movienames from table MovieMaster) if I select the movie name then the 2nd dropdownlist box should automatically filled with tname(Theatre Names) using the table "ShowDetail s". What is the query for this?

    -sweatha
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    The query is so simple .
    What have you tried so far ?

    Is there any realtionship between the tables ?

    Comment

    • sweatha
      New Member
      • Mar 2008
      • 44

      #3
      Originally posted by debasisdas
      The query is so simple .
      What have you tried so far ?

      Is there any realtionship between the tables ?
      The relationship is
      • tid is primary key in TheatreMaster Table which is the foreign key in ShowDetails Table
      • sid is primary key in ShowDetails Table
      • mid is primary key in MovieMaster which is the foreign key in ShowDetails


      I have tried the query as

      "SELECT t.tname FROM theatreMaster t,MovieMaster m,ShowDetails s WHERE m.moviename='" & DropDownList1.S electedValue & "' and m.mid=s.mid and s.tid=t.tid"

      But its not working.

      Comment

      • deepuv04
        Recognized Expert New Member
        • Nov 2007
        • 227

        #4
        Originally posted by sweatha
        The relationship is
        • tid is primary key in TheatreMaster Table which is the foreign key in ShowDetails Table
        • sid is primary key in ShowDetails Table
        • mid is primary key in MovieMaster which is the foreign key in ShowDetails


        I have tried the query as

        "SELECT t.tname FROM theatreMaster t,MovieMaster m,ShowDetails s WHERE m.moviename='" & DropDownList1.S electedValue & "' and m.mid=s.sid and s.tid=t.tid"

        But its not working.
        here the problem is with the condition 'm.mid = s.sid'

        use m.mid = s.mid and will work

        "SELECT t.tname FROM theatreMaster t,MovieMaster m,ShowDetails s WHERE m.moviename='" & DropDownList1.S electedValue & "' and m.mid=s.mid and s.tid=t.tid"

        Comment

        Working...