• We've upgraded our forums. Please post any issues/requests in this thread.

MySQL HELP :(

Joined
Feb 15, 2008
Messages
177 (0.05/day)
Likes
11
System Name Shark's Build
Processor Intel i5 4690K @ 4.4GHz (OC'd)
Motherboard ASUS Z97I-PLUS
Cooling Noctua NH-C14 heatsink core with swapped Phanteks PH-F140HP PWM
Memory Crucial Ballistix 1866MHz 2 x 4GB
Video Card(s) MSI Radeon R9 280X Gaming EDN. Twin Frozr IV 1.05GHZ 3GB
Storage 1 x 250GB Samsung 840EVO & 1 x 1TB SATA
Display(s) Samsung Syncmaster 2253BW // Acer 19" LCD
Case Corsair Obsidian 250D Mini ITX
Audio Device(s) On-Board
Power Supply EVGA Supernova NEX750B 750W ATX Power Supply 80+ Bronze
#1
Hey all!

So I'm working on an assignment and I'm getting an error when I try and load my .SQL file.

https://pastebin.com/4GajJ9MT <--- here is my code blocks

I get the error l_id doesn't exist when I have it in the limo table.

I'm a real scrub when it comes to this. Please help me :(

Edit: Fixed qualify and rental up a little by adding q_ to the foreign keys and r_ to the rental foreign keys. Now I'm getting error "Cannot add foreign key constraint" regarding the rental table create.
 
Last edited:
Joined
Nov 13, 2007
Messages
6,139 (1.67/day)
Likes
1,635
Location
Austin Texas
System Name silen8
Processor Intel i7 7820X Delidded @ 4.64Ghz / 3.1Ghz Mesh
Motherboard MSI X299 Tomahawk
Cooling 240mm Corsair H105 Intake
Memory 32 GB Quad 3434Mhz DDR4 15-16-16-38-300-1T
Video Card(s) Gigabyte GTX 1080 Ti Gaming
Storage 1Tb Samsung 960 Pro m2, 1TB Samsung 850 Pro SSD
Display(s) Dell 24" 2560x1440 144hz, G-Sync @ 165Hz
Case NZXT S340 Elite Black
Audio Device(s) Arctis 7
Power Supply FSP HydroG 750W
Mouse zowie ec-2
Keyboard corsair k65 tenkeyless
Software Windows 10 64 Bit
Benchmark Scores Cb: 2103 Multi, 209 Single, 10450 Timespy - 10150 GPU/11900 CPU, superpi 1M - 7.71s
#2
the constraint command syntax looks weird to me... (I work mostly with T-SQL but with a google this is what came up for mySQL):

CREATE TABLE Persons (
ID int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Age int,
PRIMARY KEY (ID)
);

also I usually don't declare width on PKs just leave is as int
 

Mindweaver

Moderato®™
Staff member
Joined
Apr 16, 2009
Messages
6,570 (2.08/day)
Likes
3,905
Location
Charleston, SC
System Name Sechs / EyeSeven
Processor i7 5820k @ 4.5ghz / i7 2600k @ 4.0Ghz
Motherboard X99S GAMING 7 / ASRock Z68 Extreme3 Gen3
Cooling CORSAIR Hydro Series H100i Extreme / Stock cooler... H50 leaked!..
Memory G.Skill DDR4 2800 16GB 4x4GB / G.Skill DDR3 1600 8gb 2x4GB
Video Card(s) PNY Quadro K2000 / MSI GTX 970 GAMING 4Gb
Storage Samsung 850 PRO 256GB SSD /Intel 240gb, corsair 120gb SSD, 3x 1 tb s storage
Display(s) 2x Acer G276HL 27" 1080p / 3x Acer 22" Nvidia surround
Case Phanteks “Enthoo Pro series”/ Cooler Master Storm Scout
Audio Device(s) Azalia Realtek ALC1150 / SB X-Fi Gamer
Power Supply Corsair CXM CX600M / Corsair 600w
Mouse Razer DeathAdder Chroma / Razer DeathAdder
Keyboard Razer BlackWidow Ultimate /
Software Windows 10 Pro x64 / Windows 10 Pro x64
#3
the constraint command syntax looks weird to me... (I work mostly with T-SQL but with a google this is what came up for mySQL):

CREATE TABLE Persons (
ID int NOT NULL,
LastName varchar(255) NOT NULL,
FirstName varchar(255),
Age int,
PRIMARY KEY (ID)
);

also I usually don't declare width on PKs just leave is as int
Yea, I never declare width on PKs or int's in general as well. The biggest issue I seen was not setting the pk to NOT NULL, but I see you fixed that for him in your code.

I would write it like this if I wanted to use the constraint. I would add the constraint after the PK.
Code:
CREATE TABLE limo (
l_id INT,
l_callsign VARCHAR(15),
l_type VARCHAR(300),
PRIMARY KEY(l_id),
CONSTRAINT limo_l_id_PK
);
or create table without the constraint using your code then ALTER the table
Code:
ALTER TABLE limo
ADD CONSTRAINT limo_l_id_PK;