I have these tables
create table racks (
rack_id INT NOT NULL AUTO_INCREMENT,
location VARCHAR(100) NOT NULL,
elevation VARCHAR(100) NULL,
title VARCHAR(100) NOT NULL,
power_panel VARCHAR(100) NOT NULL,
circuit_breaker VARCHAR(10) NOT NULL,
number_of_slots INT NOT NULL,
display CHAR(1) DEFAULT '1',
PRIMARY KEY ( rack_id )
);
create table devices (
device_id INT NOT NULL AUTO_INCREMENT,
rack_id INT NOT NULL,
orientation CHAR(1) DEFAULT '1',
beginning_slot DECIMAL(3,1) NOT NULL,
ending_slot DECIMAL(3,1) NOT NULL,
device VARCHAR(100) NOT NULL,
notes TEXT DEFAULT NULL,
width INT DEFAULT NULL,
beginning_x INT DEFAULT NULL,
display CHAR(1) DEFAULT '1',
updated_by VARCHAR(25) DEFAULT 'Luke Utnowski',
updated_date TIMESTAMP NOT NULL DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
FOREIGN KEY ( rack_id ) REFERENCES racks (rack_id),
PRIMARY KEY ( device_id )
);
create table connections (
connection_id INT NOT NULL AUTO_INCREMENT,
device_input_id INT NOT NULL,
device_output_id INT NOT NULL,
cable_type VARCHAR(25) NOT NULL,
display CHAR(1) DEFAULT '1',
notes TEXT DEFAULT NULL,
FOREIGN KEY ( device_input_id ) REFERENCES devices (device_id),
FOREIGN KEY ( device_output_id ) REFERENCES devices (device_id),
PRIMARY KEY ( connection_id )
);
and am trying to figure out how I can get the rack_id if I have a connection_id