473,396 Members | 1,997 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Missing Auto Population in three tables

Dear Sir,
I’m trying to write a database for an American Legion Post. To Track Members, and annual dues collection,
I wrote three tables.
1.Legion Master Table:, with Names, addresses, contact information etc.
a.KKEY is Primary Key
2.Legion Year Table: Post Address and year of operation, It allows the user to add a new year to the list.
a.YKEY is the primary Key
3.Finance Table: Record the receipt of Annual Dues from Members -date of receipt, amount paid Check number or cash.
a.I’d like the KKey, first and last name fields auto populated.
I wrote a query using the KKey and first name and no matter the relationship I express in the query, I can’t get the KKEY and first and last name to auto populate. I used K-KEY into FK_KKEY in the Finance table and YKEY into FK_YKEY. Also. in the finance table. I use a drop down to put in the correct year of the collection
What Am I doing wrong to get these three fields to auto populate from the Master database?
Help!!!
Apr 28 '20 #1
2 1350
NeoPa
32,556 Expert Mod 16PB
You should only ever populate data for Fields in Queries (See Database Normalisation and Table Structures for tips about understanding basic database work).

More than that is very difficult to help with at this point. You say a lot - but without really conveying much understanding of what you've tried & what isn't working.

You do need to remember that we only know what you tell us, and even that only if your explanation is clear. You lost me before the half-way point.
Apr 28 '20 #2
MySQL doesn't have recursive functionality, so you're left with using the NUMBERS table trick -

Create a table that only holds incrementing numbers - easy to do using an auto_increment:

DROP TABLE IF EXISTS `example`.`numbers`;
CREATE TABLE `example`.`numbers` (
`id` int(10) unsigned NOT NULL auto_increment,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
Populate the table using:

INSERT INTO `example`.`numbers`
( `id` )
VALUES
( NULL )
...for as many values as you need.

Use DATE_ADD to construct a list of dates, increasing the days based on the NUMBERS.id value. Replace "2010-06-06" and "2010-06-14" with your respective start and end dates (but use the same format, YYYY-MM-DD) -

SELECT `x`.*
FROM (SELECT DATE_ADD('2010-06-06', INTERVAL `n`.`id` - 1 DAY)
FROM `numbers` `n`
WHERE DATE_ADD('2010-06-06', INTERVAL `n`.`id` -1 DAY) <= '2010-06-14' ) x
LEFT JOIN onto your table of data based on the time portion:

SELECT `x`.`ts` AS `timestamp`,
COALESCE(`y`.`score`, 0) AS `cnt`
FROM (SELECT DATE_FORMAT(DATE_ADD('2010-06-06', INTERVAL `n`.`id` - 1 DAY), '%m/%d/%Y') AS `ts`
FROM `numbers` `n`
WHERE DATE_ADD('2010-06-06', INTERVAL `n`.`id` - 1 DAY) <= '2010-06-14') x
LEFT JOIN TABLE `y` ON STR_TO_DATE(`y`.`date`, '%d.%m.%Y') = `x`.`ts`
If you want to maintain the date format, use the DATE_FORMAT function:

DATE_FORMAT(`x`.`ts`, '%d.%m.%Y') AS `timestamp`
Apr 29 '20 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Emilio | last post by:
Hello everyone. I hope someone can help me with this. I have 3 columns called EMPLOYEE_TEST, TEST_QA and EMPLOYEE_TEST_ANSWER. The TEST_QA table contains the following: TEST_QA_ID |...
0
by: WindAndWaves | last post by:
Hi Gurus Here is another question that I have been struggling with for over a year. Basically, I would like to allow users to enter data into three tables in at the same time. The reason it...
6
by: John | last post by:
Hi I have three tables with a common id with which they can be linked. I need to merge them in a way that the resultant table has all records from three tables. Below is what sort of result I am...
7
by: cov | last post by:
I have a php query where I'm attempting to pull data from 3 different tables between a php form and mysql db. I had hoped early on to use a unique identifier to help ensure referential integrity...
1
by: doc1355 | last post by:
I have a feeling that this is an easy question. However I'm a newbee and don't have any idea how to do this. I have three tables that stores my users information. Each user has a unique ID that is...
1
by: Big X | last post by:
I have already achieved this in access and was trying with straight SQL earlier I would just like to know what I'm doing wrong in sql or what syntax I'm missing. I have three tables with identical...
3
KeredDrahcir
by: KeredDrahcir | last post by:
I have three tables. One contains main menu items, one contains sub menu items and one contains the link between main menu and sub menu items. Since more than one main menu item can have the same...
1
by: Mustafa Sherazi | last post by:
Hello, i have three tables in my database. i m trying to create one to many relationship among those three tables. relationship created between two tables, but when i try to create relationship...
23
by: Petrol | last post by:
I have a database recording the participation of people on walks. To meet normalization rules there are three tables - People, Walks and Walk_participation_history. The Walks table gives extra...
7
by: joithomas | last post by:
I have three tables. One contains ALL funds(Funds). Then I have a table that has the Representatives of the fund(FundReps)and the third table has the Recipients of the Funds(FundRecipients). I...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
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,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.