Connecting Tech Pros Worldwide Forums | Help | Site Map

Problem with Query

Member
 
Join Date: Mar 2008
Posts: 44
#1: Apr 22 '08
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 "TheatreMaster" depending on the moviename on "MovieMaster" via table "ShowDetails".

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 "ShowDetails". What is the query for this?

-sweatha

debasisdas's Avatar
Moderator
 
Join Date: Dec 2006
Location: Bangalore ,India
Posts: 7,511
#2: Apr 22 '08

re: Problem with Query


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

Is there any realtionship between the tables ?
Member
 
Join Date: Mar 2008
Posts: 44
#3: Apr 22 '08

re: Problem with Query


Quote:

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.SelectedValue & "' and m.mid=s.mid and s.tid=t.tid"

But its not working.
deepuv04's Avatar
Expert
 
Join Date: Nov 2007
Posts: 202
#4: Apr 22 '08

re: Problem with Query


Quote:

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.SelectedValue & "' 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.SelectedValue & "' and m.mid=s.mid and s.tid=t.tid"
Reply