Add another join to a query

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

  1. #1

    Default Add another join to a query

    I need to add to the SELECT item "C.CATEGORY_ID" to the following query
    (another join?):

    Category_id is a column of table "blog_categories" which has in common
    the column "entry_id"

    SELECT
    A.ENTRY_ID, A.TITLE, B.UNAME, B.ENTRY_DATE, B.COMMENT_ID
    FROM BLOG_ENTRIES A INNER JOIN BLOG_COMMENTS B ON A.ENTRY_ID=B.ENTRY_ID
    AND A.BLOG_ID=B.BLOG_ID
    WHERE
    A.BLOG_ID=<cfqueryparam cfsqltype="cf_sql_integer"
    value="#arguments.blog_id#">
    ORDER BY B.ENTRY_DATE DESC

    Thank You
    ContiW



    Conti Guest

  2. Similar Questions and Discussions

    1. sql join query
      Hi, I have a little problem that's driving me nuts, I'm sure there's a simple solution that I'm overlooking. The problem is this (I'm giving...
    2. Inner Join Query
      Hello Everyone, it's been ages since I posted here, but I just don't get table joins. The background, I am working with an Access db. There are...
    3. INNER JOIN query question
      I have 2 tables with the following columns (other data fields omitted for brevity): cases.caseid cases.uid profiles.uid profiles.locationid...
    4. SQL join query help
      I have written a forum and am using the following query to search in it: $query="select topics.tid,f_messages.messid from f_messages left join...
    5. Query, Join on nearest
      Hello, I am in a position where i need to create a query where i must join two tables on the nearest value. Imagine i have 2 tables, tbl_Trade...
  3. #2

    Default Re: Add another join to a query

    Yup.

    SELECT
    A.ENTRY_ID, A.TITLE, B.UNAME, B.ENTRY_DATE, B.COMMENT_ID, C.CATEGORY_ID
    FROM BLOG_ENTRIES A
    INNER JOIN BLOG_COMMENTS B ON A.ENTRY_ID=B.ENTRY_ID
    AND A.BLOG_ID=B.BLOG_ID
    INNER JOIN BLOG_CATEGORIES C ON A.ENTRY_ID=C.ENTRY_ID
    WHERE
    A.BLOG_ID=<cfqueryparam cfsqltype="cf_sql_integer"value="#arguments.blog_i d#">
    ORDER BY B.ENTRY_DATE DESC

    Phil

    paross1 Guest

  4. #3

    Default Re: Add another join to a query

    Thank You paross1. Unfortunately it does not work yet.
    Tablename is correct columnName ant type also is correct.
    The errorMsg returned is
    Error Executing Database Query.
    Syntax error (missing operator) in query expression ''.
    Thanks for helping.
    ContiW


    Conti Guest

  5. #4

    Default Re: Add another join to a query

    When adding joins Access (damn microsoft) requires parentheses around the
    higher join(s). Try:

    FROM (BLOG_ENTRIES A
    INNER JOIN BLOG_COMMENTS B ON A.ENTRY_ID=B.ENTRY_ID
    AND A.BLOG_ID=B.BLOG_ID)
    INNER JOIN BLOG_CATEGORIES C ON A.ENTRY_ID=C.ENTRY_ID


    JMGibson3 Guest

  6. #5

    Default Re: Add another join to a query

    That was it !
    ThankYou JMGibson3
    You have a good source of info. Share?
    Have a nice week.
    WalterConti
    Conti Guest

  7. #6

    Default Re: Add another join to a query

    Sorry, you didn't say that it was Access. Yeah, the parentheses requirement makes Access just that much more fun for query writing! Just glad that you didn't need an outer join.

    Phil :)
    paross1 Guest

  8. #7

    Default Re: Add another join to a query

    I didn't. Sorry Phil.
    I have Fry's a couple of blocks away and I have got a book.
    See, "outher joins" ... FUN!

    WalterConti
    Conti 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