Simple query question

Creating tables and queries
Post Reply
vhogandbd
Posts: 1
Joined: Thu Dec 29, 2016 6:02 pm

Simple query question

Post by vhogandbd »

I have 2 tables. One includes client data - Primary Key, Alphanumeric client ID, name, address, etc.
The second contains special due dates - Primary Key, Primary Key from Client Data table, Alphanumeric client ID, special due date, and description of project to be done.

I established a one to many relationship between client data and special due dates tables using Client Primary Key. I have 2 entries in this table.

I made a query for all items from Special Due Dates table and the client name from the client data table. The result is every client being listed twice, once with each due date.

It's been a long time since I've used databases, and never Open Office before. Please help! :crazy: Thanks
Open Office 4.1.3
Operating System Windows 7 Professional
UnklDonald418
Volunteer
Posts: 1548
Joined: Wed Jun 24, 2015 12:56 am
Location: Colorado, USA

Re: Simple query question

Post by UnklDonald418 »

That issue is usually resolved using WHERE clauses and/or Joins in the query.
That's about all I can offer since you didn't provide enough information for anyone to give you specific help with this.
If your problem has been solved, please edit this topic's initial post and add "[Solved]" to the beginning of the subject line
Apache OpenOffice 4.1.14 & LibreOffice 7.6.2.1 (x86_64) - Windows 10 Professional- Windows 11
User avatar
keme
Volunteer
Posts: 3704
Joined: Wed Nov 28, 2007 10:27 am
Location: Egersund, Norway

Re: Simple query question

Post by keme »

Even though you have established a relationship for your tables, your query needs to specify the relationship again. Predefined relationships maintains data integrity (if set up properly), but does not limit the possibilities for data extraction by queries. Most likely you made a "cross join" in your query where you want left (or possibly inner) join.

In your query (SQL view) you must have a "join" statement for the second table. After "Join <tablename>" add something like "ON Client.ID=DueDates.ClientID" (Replace with your actual table/field names, of course)

The ON keyword establishes a relationship for the scope of the query.
Apache OO 4.1.12 and LibreOffice 7.5, mostly on Ms Windows 10
Post Reply