It's my first post and first DB application.
Environment: MFC DAO, MS Access database
I want to have several tables which have links to the fields to other
tables. The following example explains the basic idea.
CREATE TABLE husbands (
id COUNTER,
name TEXT,
age LONG,
wife_id LONG);
CREATE TABLE wives (
id COUNTER,
name TEXT,
age LONG,
husband_id LONG);
Now, I want to create the query which returns me all guys whose wives
are, say, older than 21. Any hints and links are welcomed.
Alexei. 3 2815
<iv***********@ gmail.com> schreef in bericht news:11******** *************@j 55g2000cwa.goog legroups.com... It's my first post and first DB application. Environment: MFC DAO, MS Access database I want to have several tables which have links to the fields to other tables. The following example explains the basic idea. CREATE TABLE husbands ( id COUNTER, name TEXT, age LONG, wife_id LONG); CREATE TABLE wives ( id COUNTER, name TEXT, age LONG, husband_id LONG); Now, I want to create the query which returns me all guys whose wives are, say, older than 21. Any hints and links are welcomed. Alexei.
IMO your basic idea is not a good idea.
What if someone has a partner of the same sex?
also: Do *not* store age but calculate the age!
I would suggest that you Create a Table TblPersons
with a field like Sex (Male or Female)
BirthDate instead of Age
Partner_ID instead of husband_id / wife_id
Search Google (this group) for a function to calculate age when you have the BirtDate.
Arno R
Thanks for your comments, you're right (my sample was not very safe and
politically correct).
But... I'm afraid I have not stated the problem clearly. I had problem
with building the queries, not with the structure of the table.
Actually, I'm working on "audio DB" which has multiple tables which I
wanted to connect just like [husbands] and [wives], i.e. via "id"
field. The sample I gave was realy abstract, just to show how the
tables are related. As I understood now (after 2 h search) I needed
something like subquery or INNER JOIN.
Moreover, in my audio DB app I have one "main" table connected to two
other tables. Now, assume that I extended [husbands] properly and the
table [children] is similar to [wives]. Do you have any comments about
this solution (can it be done faster, "better")? And another question:
how can I use INNER JOIN for this example?
"Searching for guys with wives older than 21 and children younger than
7"
------------------
SELECT husbands.*
FROM husbands, wives, children
WHERE husbands.wife_i d = wives.id AND husbands.child_ id = children.id
AND wife.age>21 AND children.age<7
------------------
"Axel" <iv***********@ gmail.com> schreef in bericht news:11******** **************@ c74g2000cwc.goo glegroups.com.. . Thanks for your comments, you're right (my sample was not very safe and politically correct). But... I'm afraid I have not stated the problem clearly. I had problem with building the queries, not with the structure of the table. Actually, I'm working on "audio DB" which has multiple tables which I wanted to connect just like [husbands] and [wives], i.e. via "id" field. The sample I gave was realy abstract, just to show how the tables are related. As I understood now (after 2 h search) I needed something like subquery or INNER JOIN. Moreover, in my audio DB app I have one "main" table connected to two other tables. Now, assume that I extended [husbands] properly and the table [children] is similar to [wives]. Do you have any comments about this solution (can it be done faster, "better")? And another question: how can I use INNER JOIN for this example? "Searching for guys with wives older than 21 and children younger than 7" ------------------ SELECT husbands.* FROM husbands, wives, children WHERE husbands.wife_i d = wives.id AND husbands.child_ id = children.id AND wife.age>21 AND children.age<7 ------------------
SELECT Husbands.*
FROM (Husbands INNER JOIN Wives ON Husbands.ID = Wives.ID)
INNER JOIN Children ON Husbands.ID = Children.ID
WHERE (Wives.Age)>21 AND Children.Age<7
Just select the tables in the query grid and connect the ID-fields to get the INNER JOIN.
Arno R This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Chris Powell |
last post by:
I am using Excel/Access 2000 and have two large Excel files (25,000 rows
each) that I wish to create linked tables in Access rather than
importing into Access. The two source Excel files change frequently, so
I want to:
A) prompt the user, using a custom form, for the specific Excel files to
be linked;
B) create the links dynamically;
C) insert the linked tables into a select query grid and include the SQL
statement in the VBA...
|
by: Internet Arrow Limited |
last post by:
Hi,
I have a requirement to write an access application that must run
under access97 and access2K. Some users will use Acess2K to access
data that will also be accessed by Access97 users. The source data
must therefore remain in Access97 format
The user community has a mixture of access97 on WinNT; access2K on
winNt and access2K on win2K.
|
by: Alfonso Esteban Gonzalez Sencion |
last post by:
I am trying to use Access as a front end for extracting information from
an Oracle database. I started using linked tables but I am getting a
very curious behaviour.
When I consult the linked table in access, the total number of records
is OK but some records appear several times and some records do not
appear at all. It seems as if access or the ODBC drivers returns several
times the same record and skips some of the records, curiosly...
|
by: Joe |
last post by:
I am using Access 2003 and are linking to an Oracle 9i ODBC datasource
(using Oracle ODBC drivers). After linking the tables in Access, I inspect
the data contained in the linked tables. For tables that involve a number
field as the primary key, the data is returned successfully. For tables
that involve a character field (e.g. CHAR(3) or VARCHAR(10)) as the primary
key, I have the correct number of rows returned, but the data displayed...
|
by: Lewis Veale |
last post by:
I have an Access 2000 front-end pointing at a SQL Server backend, with
around 80 linked tables and views. I frequently need to point the
front-end at different versions of the back-end, and achieve this by
relinking the tables and views to use a different DSN.
I use the Linked Table Manager > Select All > and tick the 'always
prompt for a new location' box, then click OK. It correctly pops up
the 'select data source' box, from which I...
| |
by: brettclare |
last post by:
I have linked a large SQL Server table to Access, however 'only'
2,195,439 records are shown and are available to query. Can I increase
the size (cache??)/number of records showing in Access?
Thank you.
|
by: BillCo |
last post by:
I've been running a text-to-table import as part of a daily routine for
years and I've just added a few new fields and updated the import spec.
The strange thing is that it works perfectly when importing to a local
table, but once I try to run it on an identical linked table it spits
up a "numeric field overflow" error.
In the past it has imported to the linked table with no problems, but
it's been doing this since I increased the number...
|
by: Chandan Ahuja |
last post by:
Hello ,
I use MFC DAO classes to access my MS access database .
I am using some linked tables(Linked to Oracle) in my MS Access database .
Also i have some queries in my databse , these queries select some rows from the linked tables and insert them in MS access local tables .
I am facing problem while executing these queries .
The problem is that -- through the code ; when i am asking these query to execute , it prompts...
|
by: bubbles |
last post by:
Using Access 2003 front-end, with SQL Server 2005 backend.
I need to make the front-end application automatically refresh the
linked
SQL Server tables.
New tables will be added dynamically in the future, so the front-end
application
must have a way to keep up with this (instead of manually linking
them).
|
by: Bobby |
last post by:
Hi,
Not sure if this is Access, SQL or ODBC. I have a SQL database with an
Access Front End. They are linked with ODBC. Occasionally (it's
happened 3 times in 4 months) some of the linked tables in Access
become read only and I can't add new records to them. If I go into
design view (in Access) the tables have lost their Primary Key. In
SQL, they still work just fine. The only way I have found to get the
links working again is to delete...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
|
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |