MySQL Forums
Forum List  »  General

Re: Help - complex joins
Posted by: Bad Programmer
Date: May 31, 2020 05:16PM

I can give you access to the test database but I'd need an IP to grant permission to access the db server. Some kind of a private message would help. I'd rather not broadcast the creds here.

I've tried multiple versions of joins. The closest I've gotten was with my SELECT in the JOIN which you see in my original post. It doesn't throw an error but the averages & counts are wrong.

The structure is pretty straight forward.
The FieldID in the atttrib_ tables is a foriegn key for the RecordID in the tables they relate to.

CREATE TABLE `answers` (
`RecordID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`AttributionID` int(11) DEFAULT NULL,
`RatingID` bigint(20) unsigned DEFAULT NULL,
`EmployeeID` bigint(20) DEFAULT NULL,
`Score` smallint(20) unsigned DEFAULT NULL,
`DateCreated` datetime DEFAULT NULL,
PRIMARY KEY (`RecordID`)
) ENGINE=MyISAM AUTO_INCREMENT=4761 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

CREATE TABLE `division` (
`RecordID` smallint(4) unsigned NOT NULL AUTO_INCREMENT,
`Entry` varchar(150) COLLATE utf8mb4_unicode_ci NOT NULL,
PRIMARY KEY (`RecordID`),
UNIQUE KEY `Entry` (`Entry`)
) ENGINE=MyISAM AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

CREATE TABLE `attrib_division_rl` (
`RecordID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`AttributionID` int(10) unsigned NOT NULL,
`FieldID` int(10) unsigned NOT NULL,
PRIMARY KEY (`RecordID`),
UNIQUE KEY `AttributionField` (`AttributionID`,`FieldID`)
) ENGINE=MyISAM AUTO_INCREMENT=49 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci

CREATE TABLE `organization` (
`RecordID` int(10) unsigned NOT NULL AUTO_INCREMENT,
`Name` varchar(200) COLLATE utf8_unicode_ci NOT NULL,
`SubName` varchar(50) COLLATE utf8_unicode_ci DEFAULT NULL,
`DateCreated` datetime DEFAULT NULL,
PRIMARY KEY (`RecordID`),
UNIQUE KEY `OrgName` (`Name`,`SubName`)
) ENGINE=MyISAM AUTO_INCREMENT=37 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci

CREATE TABLE `attrib_organization_rl` (
`RecordID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`AttributionID` bigint(20) unsigned DEFAULT NULL,
`FieldID` int(10) DEFAULT NULL,
PRIMARY KEY (`RecordID`),
UNIQUE KEY `AttributionID` (`AttributionID`,`FieldID`)
) ENGINE=MyISAM AUTO_INCREMENT=47 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci

CREATE TABLE `employee` (
`RecordID` bigint(20) unsigned NOT NULL AUTO_INCREMENT,
`EmployeeID` bigint(20) DEFAULT NULL,
`FName` varchar(75) COLLATE utf8_unicode_ci NOT NULL,
`MidInit` varchar(1) COLLATE utf8_unicode_ci DEFAULT ' ',
`LName` varchar(75) COLLATE utf8_unicode_ci DEFAULT NULL,
`DateCreated` datetime DEFAULT NULL,
PRIMARY KEY (`RecordID`),
UNIQUE KEY `Name` (`FName`,`LName`,`MidInit`)
) ENGINE=MyISAM AUTO_INCREMENT=646 DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci

Options: ReplyQuote


Subject
Written By
Posted
May 27, 2020 01:44PM
Re: Help - complex joins
May 31, 2020 05:16PM
June 02, 2020 10:00AM
June 02, 2020 08:03PM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.