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

  1. #1

    Default 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
    currently 2 tables, tbl_Images and tbl_Category. The field
    tbl_Images.ImgCategory is a "look up" gotten by table/query from the
    tbl_Category.CategoryID. Which is the primary key in tbl_Category.

    I am trying to get all the data from tbl_Images and the tbl_CategoryName
    from the tbl_Category. tbl_Images holds fields ImgID, ImgNumber,
    ImgCategory, ImgLink. Now the field of tbl_Images.ImgCategory holds a number
    (tbl_Category.CategoryID). The table Category has 2 fields, the ID (primary
    Key) and the Category Name. So, when an Image is added to the Image table
    the category is set to use the primary key from the category table.

    However, when I output the image table data I want the
    tbl_Category.CategoryName to show not the tbl_Category.CategoryID, but I
    can't figure out how to join the tables so that I get that data. So far the
    query I am using says that there is a mismatch on data type.

    QUERY:
    <cfquery name="ShowImages" datasource="#request.dsn#">
    SELECT tbl_CategoryID, tbl_CategoryID, tbl_Images.*
    FROM tbl_Category INNER JOIN tbl_Images ON tbl_category.CategoryID =
    tbl_Images.ImgCategory</cfquery>

    The query above tells me there is a mismatch data type. So, how do I get
    this to work and also to output the Name of the category and not the number
    for grouping by Name.


    Thanks,

    Kim


    KimMazz 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. 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...
    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: Inner Join Query

    Please provide the exact column names and data types from BOTH tables, and
    their relationships (id-id, etc.) Since you are only relating two columns
    (tbl_category.CategoryID = tbl_Images.ImgCategory) it looks like these are of
    different types.

    Phil

    paross1 Guest

  4. #3

    Default Re: Inner Join Query

    Phil

    Yes, I did find that out. I had the data type on one set to autonumber since
    it's the primary key and the other was set to text. Once I changed that to
    number the query worked.

    Thanks for responding I appreciate it.

    Kim

    "paross1" <webforumsuser@macromedia.com> wrote in message
    news:e6mone$mch$1@forums.macromedia.com...
    > Please provide the exact column names and data types from BOTH tables, and
    > their relationships (id-id, etc.) Since you are only relating two columns
    > (tbl_category.CategoryID = tbl_Images.ImgCategory) it looks like these are
    > of
    > different types.
    >
    > Phil
    >

    KimMazz 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