4 table JOIN problem

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

  1. #1

    Default 4 table JOIN problem

    I am struggling to come up with the proper JOIN syntax for this SQL query. It
    is for an Access Database. I am receiving a column name (#person_type) and
    value (#person_value) from a form. I need the requestor_id from the requestor
    table, which I can use to pull up all of the requests from table requests. But
    I also need the status of each request which is mapped in the status table,
    with status.status_id related to the status_def table giving me the description
    for the status_id.

    The error I am getting missing operator. I've tried so many combinations of
    LEFT, OUTER, and INNER JOINS that I don't know if I am doing myself any good
    any more. HELP!

    :confused;

    SELECT r.request_id, r.title, r.author, r.callnum, r.article_title, r.barcode,
    sd.status_id, sd.definition, s.status_id, rby.requestor_id
    (FROM requestors rby LEFT JOIN requests r ON rby.requestor_id = r.requestor_id)
    LEFT JOIN status s ON r.request_id = s.request_id
    INNER JOIN status_def sd ON s.status_id = sd.status_id
    WHERE rby.#person_type# = '#person_value#'

    TimMcGeary Guest

  2. Similar Questions and Discussions

    1. three table outer join with aggregate functions
      here is a query joining three tables (SQL 2000) that doesn't return the results i need. SELECT o.OutID, o.GroupID, o.OutTitle, o.SubHead,...
    2. Join on virtual table
      Hi. I'd like to return a result set from a plpgsql function constructed out of a 'virtual table' joined to an actual table, and struggling to find...
    3. How can join two table in one datagrid?
      Hi all, I have a two tables as following, 1.Customer table - cust_no - cust_name - cust_number 2. Sales table - sale_no
    4. Newbie - Easy (I think) SQL Syntax Question, 3 table join
      I have three identical tables, t1, t2, t3 Each table contains a complete list of files on a particular server. One of the fields in each table...
    5. Cant Bind a data from a multi-table Inner Join using C#
      Hi Guys. i am using C#.net connecting to an Access database using OleDbConnection i am using the following select Statement to join 3 tables ...
  3. #2

    Default Re: 4 table JOIN problem

    did you tried without the parenthesis around the (From ....)
    jorgepino Guest

  4. #3

    Default Re: 4 table JOIN problem

    Passing URL parameters used directly in a cfquery is risky, so you should read
    up on sql injection risks.

    Access requires a lot of ugly parenethesis for JOINS. I guess that is how it
    establishes JOIN precedence and resolves ambiguity. Are LEFT JOINS required
    here, or were you just trying to get the query to work? If you only want to
    return records where all of the tables contain matching records, then use INNER
    JOINS. This should be the right syntax for Access

    SELECT r.request_id, r.title, r.author, r.callnum, r.article_title, r.barcode,
    sd.status_id, sd.definition, s.status_id, rby.requestor_id
    FROM ( (requestors rby INNER JOIN requests r ON rby.requestor_id =
    r.requestor_id)
    INNER JOIN status s ON r.request_id = s.request_id)
    INNER JOIN status_def sd ON s.status_id = sd.status_id
    WHERE rby.#person_type# = '#person_value#'





    mxstu Guest

  5. #4

    Default Re: 4 table JOIN problem

    correct but you had
    ( FROM requestors rby LEFT JOIN requests r ON rby.requestor_id = r.requestor_id)
    instead of
    FROM (requestors rby LEFT JOIN requests r ON rby.requestor_id = r.requestor_id)

    jorgepino Guest

  6. #5

    Default Re: 4 table JOIN problem

    mxstu, I had actually tried this... almost. I didn't have the ( )'s properly
    set. Thank you for your editing of it. It works.

    I have never heard of any risks of passing URL parameters into cfqueries. In
    fact, the ColdFusion training I had advocated it in the examples.

    Can you point me to documentation of the risks? I would definitely like to
    read up on it.

    Also - can you briefly state some of the risks or what I should do instead?

    Thanks!

    TimMcGeary Guest

  7. #6

    Default Re: 4 table JOIN problem

    if you realy want to be safe you should use <cfqueryparam>

    Select LastName
    form tablelist
    WHERE LastName= <cfqueryparam value="#LastName#" cfsqltype="CF_SQL_VARCHAR" maxlength="17">
    jorgepino Guest

  8. #7

    Default Re: 4 table JOIN problem

    Excellent. Thank you that.
    TimMcGeary Guest

  9. #8

    Default Re: 4 table JOIN problem

    TimMcGeary,

    Generally speaking, sql injection is when a user attempts to pass sql commands
    through form or url variables, in an attempt to make your sql query perform in
    a way that you did not intend. For example, passing an extra statement that
    would cause your query to delete information from other tables or cause a login
    query to successfully authenticate an invalid user. Any time you accept input
    from users that will be used in a SQL query (ex. url or form variables), you
    need to guard against sql injection. Macromedia recommends using the
    CFQUEYRPARAM tag to protect against sql injection.

    IMO, a good rule is to never blindly accept URL and FORM variables.


    [url]http://livedocs.macromedia.com/coldfusion/6.1/htmldocs/tags-b20.htm[/url]

    mxstu 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