Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 212397
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:10:59+00:00 2026-05-11T18:10:59+00:00

I have quite a problem concerning the use of relational database concepts in Delphi

  • 0

I have quite a problem concerning the use of relational database concepts in Delphi 2009 with MyDAC.

I have a database structure that looks somehow like the following:


Item

  • id
  • name

Storage

  • id
  • name

StorageItem

  • id
  • item_id
  • storage_id
  • place

Now when I have an active dataset from “Item” how can I display all associated Storages in for example a DBGrid?

By the way: Would it be better to not use “id” in every table but to alter it and use something like for example “id_item” or “id_storage”?

Thank you in advance 🙂

  • 1 1 Answer
  • 3 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T18:10:59+00:00Added an answer on May 11, 2026 at 6:10 pm
    Select a.ID, b.Name, a.Place
    from StorageItem a
    inner join Storage b
    on (a.id = b.id)
    

    the above query will return all the items in StorageItem table with it’s name, now if you want to filter it to return only items for a specific item add where clause to be like

    Select a.ID, b.Name, a.Place
    from StorageItem a
    inner join Storage b
    on (a.id = b.id)
    where a.item_id = 1 -- place the item id here
    

    you can use where with parameters such as:

    MyQuery.Sql.Text := ' Select a.ID, b.Name, a.Place from StorageItem a
    + ' inner join Storage b on (a.id = b.id) '
    + ' where a.item_id = :ItemNo ';
    MyQuery.ParamByName('ItemNo').asInteger := 1;
    MyQuery.Open;
    

    and assign the query above to dbGrid

    also you can use MasterSource property to make the relations without using the “where” part

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this quite popular problem, but have failed to find a solution that
I have a problem, concerning the jdk/jre usage of my eclipse. I know that
I have quite simple problem in SQL Server: User can have 12 items that
I have quite a strange problem with PHP and Apache on my local testing
I have a quite common problem, as I saw in the various user groups
I have a quite specific problem. I created a webapp and want to have
I have faced this problem quite often during the last couple of months, during
I have come across quite a wired problem right now. I am using ASP.NET
My problem is quite simple: I have a 400MB file filled with 10,000,000 lines
The problem is quite basic. I have a JTable showing cached data from a

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.