By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,362 Members | 1,337 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,362 IT Pros & Developers. It's quick & easy.

Problem with Query

P: 44
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
Apr 22 '08 #1
Share this Question
Share on Google+
3 Replies


debasisdas
Expert 5K+
P: 8,127
The query is so simple .
What have you tried so far ?

Is there any realtionship between the tables ?
Apr 22 '08 #2

P: 44
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.
Apr 22 '08 #3

deepuv04
Expert 100+
P: 227
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"
Apr 22 '08 #4

Post your reply

Sign in to post your reply or Sign up for a free account.