Professional Web Applications Themes

MULTIPLE TABLE QUERY! - ASP Database

I am trying to retrieve data based on data in three tables. Not quite sure how to proceed. //Logic // retreve cost item data, category_name assocociated with cost_item.category_id in category table where category_id is associated with category_group.category_group_id = 3 SELECT cost_item.cost_item_name, cost_item.cost_item_amount, category.category_name, cost_item.cost_item_id, category_group.category_group_name FROM cost_item , category, category_group " &_ WHERE cost_item.cost_item_category = category.category_id " &_ Above is my feeble attempt. If anyone can help me figure this out..it would be appreciated. AJ...

  1. #1

    Default MULTIPLE TABLE QUERY!

    I am trying to retrieve data based on data in three tables.
    Not quite sure how to proceed.

    //Logic
    // retreve cost item data, category_name assocociated with
    cost_item.category_id in category table where category_id is associated with
    category_group.category_group_id = 3

    SELECT
    cost_item.cost_item_name,
    cost_item.cost_item_amount,
    category.category_name,
    cost_item.cost_item_id,
    category_group.category_group_name
    FROM
    cost_item , category, category_group " &_
    WHERE
    cost_item.cost_item_category = category.category_id " &_

    Above is my feeble attempt.

    If anyone can help me figure this out..it would be appreciated.

    AJ


    Anthony Guest

  2. #2

    Default Re: MULTIPLE TABLE QUERY!

    You may post the structure of the 3 tables you are working with. It would be
    easier to see what you exactly want to do.


    "Anthony Judd" <com.au> wrote in message
    news:phx.gbl... 
    with 


    Agoston Guest

  3. #3

    Default Re: MULTIPLE TABLE QUERY!

    Use INNER JOIN clauses to match up fields that are common between the
    tables. One idea is to use the SQL view designer to come up with the query
    in a visual manner.

    SELECT
    cost_item.cost_item_name,
    cost_item.cost_item_amount,
    category.category_name,
    cost_item.cost_item_id,
    category_group.category_group_name
    FROM
    cost_item INNER JOIN category ON
    cost_item.cost_item_category = category.category_id
    INNER JOIN category_group ON
    category.category_groupid = category_group.category_groupid
    WHERE
    .... add your restrictions here

    --
    Manohar Kamath
    Editor, .netWire
    www.dotnetwire.com


    "Anthony Judd" <com.au> wrote in message
    news:phx.gbl... 
    with 


    Manohar Guest

Similar Threads

  1. 2 table query problem
    By glossen in forum Coldfusion Database Access
    Replies: 2
    Last Post: May 24th, 12:01 PM
  2. Insert Multiple INTO multiple table
    By Andy in forum Macromedia Exchange Dreamweaver Extensions
    Replies: 2
    Last Post: April 19th, 04:09 PM
  3. CAML Query: Multiple Query Fields Issue
    By Jon F. in forum ASP.NET Web Services
    Replies: 0
    Last Post: May 12th, 08:19 PM
  4. UPDATE MULTIPLE ROWS IN ONE TABLE OBTAINING SUMS FROM ANOTHER TABLE
    By Jon Spartan in forum Microsoft SQL / MS SQL Server
    Replies: 2
    Last Post: July 9th, 04:48 PM

Bookmarks

Posting Permissions

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