Professional Web Applications Themes

query problem, #temptable - Microsoft SQL / MS SQL Server

studentID,# of exams, # of passGrades, exam, result Database is designed to return all above but it prints the exam and result part only if result < 50. select studentID,# of exams, # of passGrades, exam, result from A, B, C where C.result < 50 resulted in nothing to return if there are no result < 50. How to use select,join,etc to solve this problem?. How about if all is put in #temptable and deal from one table?. what would be query in this case?. -- Sent by mail4u9999 from yahoo within area com This is a spam protected message. ...

  1. #1

    Default query problem, #temptable

    studentID,# of exams, # of passGrades, exam, result
    Database is designed to return all above but it prints
    the exam and result part only if result < 50.

    select studentID,# of exams, # of passGrades, exam,
    result
    from
    A, B, C
    where C.result < 50

    resulted in nothing to return if there are no result <
    50.

    How to use select,join,etc to solve this problem?.
    How about if all is put in #temptable and deal from one
    table?. what would be query in this case?.





    --
    Sent by mail4u9999 from yahoo within area com
    This is a spam protected message. Please answer with reference header.
    Posted via http://www.usenet-replayer.com/cgi/content/new
    mail4u9999@yahoo.com Guest

  2. #2

    Default Re: query problem, #temptable

    The problem is not clear, but here is an attempt:
    I would guess that the tables A, B, C are related in some way (by primary
    and foreign keys) and that you want to write a query like this:
    SELECT
    studentID, numExams, numPassGrades, exam, result
    FROM
    A
    INNER JOIN B ON A.idColumn = B.fkColumn
    INNER JOIN C ON A.idColumn = C.fkColumn AND C.result < 50

    You do not need temporary tables for this. Maybe you can post your table
    design and more information can be given.
    --
    HTH,
    SriSamp
    Please reply to the whole group only!
    http://www32.brinkster.com/srisamp

    "com " <ip-mobilphone.net> wrote in
    message news:l.1061444074.1722076416[63.127.215.130]... 


    SriSamp Guest

  3. #3

    Default Re: query problem, #temptable

    > resulted in nothing to return if there are no result < 50. 

    Use left join. Like

    from
    A join B on somecondition left join C on somecondition and C.result < 50

    Or you can keep the original where clause.

    Regards
    KR

    "com " <ip-mobilphone.net> wrote in
    message news:l.1061444074.1722076416[63.127.215.130]... 


    Kresimir Guest

  4. #4

    Default Re: Re: query problem, #temptable

    Dear SriSamp,

    In your posting Re: query problem, #temptable from Thu, 21 Aug 2003
    11:52:30 +0530 you write:
     [/ref]


    Dept:
    Deptid
    Deptname

    gradesId:
    gradeid
    classid

    classes:
    Deptid
    classid

    TestResid:
    Deptid
    gradeid
    score

    return classid all the time and gradeid only if score
    < 50.

    My test query:
    select classes.classid,gradeid from classes left join
    TestResid on classes.Deptid = TestResid.Deptid and
    score < 50

    this returns more classid than they are actually in
    that department.








    --
    Spam protected message from:
    Sent by mail4u9999 from yahoo subpart from com
    Posted via http://www.usenet-replayer.com/cgi/content/new
    mail4u9999@yahoo.com Guest

Similar Threads

  1. Query problem, please help.
    By Raphael Emportu in forum MySQL
    Replies: 2
    Last Post: April 27th, 10:14 AM
  2. Query of Query problem
    By JakeFlynn in forum Macromedia ColdFusion
    Replies: 18
    Last Post: August 11th, 08:15 AM
  3. Query on Query and CF casting problem
    By obxlefty in forum Coldfusion - Advanced Techniques
    Replies: 0
    Last Post: May 18th, 12:44 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139