Help needed on a SQL Query

Results 1 to 3 of 3

Thread: Help needed on a SQL Query

  1. #1
    Join Date
    Dec 1969

    Default Help needed on a SQL Query

    Hi guys,<BR> I&#039;m a bit rusty on my SQL and need help to construct a query.<BR><BR>I have a database with some tables but the three that are necessary to my query are detailed below:<BR><BR>Table - LiveTest<BR>Fields - Module,Topic,SubTopic,Password,TestID,LecturerID,T est_Time,Test_Date<BR><BR>---------<BR><BR>Table - Questions<BR>Fields - Module,Topic,SubTopic,Question,Graphic,LecturerID, QuestionID,QuestionStyle<BR><BR>----------<BR>Table - Answers<BR>Fields - <BR>Wrong_Answers_1<BR>Wrong_Answers_2<BR>Wrong_An swers_3<BR>Right_Answer<BR>LecturerID<BR>QuestionI D<BR>-------------------------------------------------<BR><BR>Now the query I want to construct is that when a user logs into a test using the appropriate testid then all the questions and answers for that test are gathered.<BR><BR>I&#039;ve tried a few things but what I need is something like<BR><BR>Select * from LiveTest, Questions, Answers Where TestID = Input And Livetest.Module, LiveTest.Topic, LiveTest.Subtopic = Questions.Module, Questions.TOpic, Questions.Subtopic (Only get records where all these three values equal each other in the dBASE) AND Questions.QuestionID = Answers.QuestionID.<BR><BR>That&#039;s something like I need but it isn&#039;t right.I only want the questions that are relevant to the testid that is input and then the answers for these questions.<BR><BR>All help and advice would be greatly appreciated.<BR>GER

  2. #2
    Join Date
    Dec 1969

    Default RE: Help needed on a SQL Query

    i think you can only query one table at a time... if you&#039;re selecting all the fields from a table, just do "SELECT * FROM tablename" it&#039;ll be a lot easier than typing all the fields out<BR><BR>syntax should be:<BR><BR>SELECT fields FROM tablename WHERE field (=,&#060;,&#062;,etc) variable ORDER BY field,field (ASC,DESC)<BR><BR>things you change are in lower case, things with multiple options are in ( parethesis )... but i&#039;m sure you figured that out ;-)

  3. #3
    Nils Bilhorn Guest

    Default RE: Help needed on a SQL Query

    select *<BR> from LiveTest l,<BR> Questions q,<BR> Answers a<BR> where l.module = q.module<BR> and l.topic = q.topic<BR> and l.subtopic = q.subtopic<BR> and q.questionid = a.questionid<BR> and l.testId = &#060;input&#062;

Posting Permissions

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