Ask a Question related to Coldfusion Database Access, Design and Development.

  1. #1

    Default inner join

    need some help with some sql I can't seem to get the syntax right. I've tried several but to no avail the one below gets me the
    closest but I can't get the guardians records pulled.

    SELECT SUM(tuition)
    FROM child INNER JOIN guardian ON guardian.ID = child.child_ID

    I would like the results to show the records from the guardian table as well

    tables:
    GUARDIAN
    fields:
    ID
    guardian1_first
    guardian1_last

    CHILD
    fields:
    ID
    child_ID
    first_name
    last_name
    tuition

    relationship: guardian.ID = child.child_ID

    results should show:

    guardian1_first, guardian1_last, and the SUM(child.tuition) for all children where the child_ID is equal to the ID of guardian
    listed

    any help would be much appreciated, I've been driving myself mad with this


    jjrmy1 Guest

  2. Similar Questions and Discussions

    1. Is left-join faster then inner join?
      Some people said that using left-join is generally faster than inner join, is that true? Thanks...
    2. JOIN vs no JOIN
      Is there any benefit in doing: SELECT a.f1, a.f2, b.f3 FROM t1 a INNER JOIN t2 b ON a.f1=b.id WHERE a.f1> 0 rather than SELECT a.f1, a.f2,...
    3. Is self-join appropriate?
      Please forgive me if this post is too long. I was trying to solve this (probably simple) issue for all day but I'm not as good in SQL as I thought...
    4. SQL join
      I am trying to join three acess tables in a recordset and trying to acess their their contents. for ex . if we have a customer table having fields...
    5. How to Join...
      I have two tables TableA Name, DeptNum, SubDeptNum JDoe, 1001, 1004 TableB Number, Name
  3. #2

    Default Re: inner join

    All you have to do is include the columns in the select statement, like below.

    select guardian1_first, guardian1_last, and the SUM(child.tuition)
    from guardian inner join child
    on guardian.id = child.childid
    group by guardian1_last, guardian1_first

    You will have to include a group by statement, as I did above, since there is
    an aggregate function in the select statement.

    Hope that this helps. Thanks.

    Chris

    cgsj_usa@yahoo.com Guest

Posting Permissions

  • You may not post new threads
  • You may 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