Query problem - multiple left joins??

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

  1. #1

    Default Query problem - multiple left joins??

    I have an employee table, and an organization table. The employee table
    contains an ouID link which always has a match in the org.table. The employee
    table also has ouID2, ouID3, and ouSubID fields which do not always have a
    match in the org.table. How do I create a query to access all records and
    information?

    <cfquery datasource = "#db#" name = "branch">
    select a.lname, a.fname, a.ext, a.voicemail, a.title, c.ou, c.ouid, c.ouFax,
    c.ouCell, c.ouToll
    from (emptbl a, loctbl b, outbl c where a.active = 'Yes' and a.locid = b.locid
    and a.ouid = c.ouid and a.active = 'Yes')
    left join a.ouid2 on c.ouid left join a.ouid4 on c.ouid left join a.ouSubID on
    c.ouid
    order by title asc
    </cfquery>

    RuBot Guest

  2. Similar Questions and Discussions

    1. Beginners question on LEFT JOINS
      Yeah, I know this was KINDA covered in databases, but could somebody give me a refresher of what a left join is in, say, terms of tables FOO and...
    2. Multiple Joins in one Query for CFGRID
      Hello, I am tring to combine all 4 queries into 1 so that it will work in a CFGRID and it's a little beyond my SQL experience. I have all this...
    3. multiple inner joins
      Hi, im a newbi to coldfusion and i need to multiple inner joins between tables in a database - some one has give me the sql version(from an old...
    4. [PHP] Are left joins more efficient?
      THese are very different things, generally. The first join is an INNER join. It pulls all records that have the matching ids. The left join is...
    5. Help on Multiple JOINS
      Paul Eaton wrote: Yes, unless it's Access, which is really picky about using parentheses to group the joins. If you're using Access, use the...
  3. #2

    Default Re: Query problem - multiple left joins??

    do a natural join to the organization table using ouID.
    Then do left joins to the organization table using the other fields.

    give a different alias to the organization table on each join.
    Dan Bracuk 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