Help with SQL

BTCWorker

Registered Member
Joined
Apr 8, 2015
Messages
71
Reaction score
7
Ok, hope someone can help me out.

I am 39 yrs old and have finally gotten around to going back to school. In my first year of a 4 yr degree in Programming. I am acing my html, css class and networking is so far pretty straight forward, but database?? Fuck!

I don't get it... the bad part is I thought I WAS getting it but I cannot figure out what the hell I am doing wrong here

I am posting the link to Gyazo for screen shots of the online app we use for assignments (I typed the text inside the query box)...

SCREEN

I am not looking for someone to just give me all of the answers! I am looking for a way to understand this easier and see where I screwed up. The textbook is not much easier to grasp for some reason. If anyone can help, I would appreciate it.
 
Your UPDATE would be a INSERT INTO there

You insert data with INSERT, you update data with UPDATE
 
I tried INSERT and it tells me that I am trying to insert a duplicate entry for "ID #4"
 
Yeah because the record it is probably already there in that table?
 
That's where I am lost. The info you see on the screen is the question given to us by the professor. It is all the info I have... I assumed I was using certain keys wrong. ie; ( ), ' , ".. or not formatting it right or whatever...
 
Tell your professor that at least the record with ownerid 4 is already inserterd into that table and the database is complaining everytime you execute the whole statement because of that
 
Thanks, That is exactly what I did. You would think that the college would have some sort of lab set up for this, but we are using a free web app... Makes no sense really... the book is crazy, it tries to tell you how to do it, but then has to put in 20 disclaimers about what will work with this system and what wont work with that system and its confusing as hell.. I am currently reading w3schools tutorials on sql. If anyone else knows any good resources, I would appreciate it.

Thanks
 
Ok, hope someone can help me out.

I am 39 yrs old and have finally gotten around to going back to school. In my first year of a 4 yr degree in Programming. I am acing my html, css class and networking is so far pretty straight forward, but database?? Fuck!

I don't get it... the bad part is I thought I WAS getting it but I cannot figure out what the hell I am doing wrong here

I am posting the link to Gyazo for screen shots of the online app we use for assignments (I typed the text inside the query box)...

SCREEN

I am not looking for someone to just give me all of the answers! I am looking for a way to understand this easier and see where I screwed up. The textbook is not much easier to grasp for some reason. If anyone can help, I would appreciate it.

You should be doing it with an INSERT. However, the ID (OwnerID) is autogenerated, ignore it, dont mention it in the fields or values.
 
Offtopic: Congrats on going back to school at 39, mate. Awesome decision.

Check out SQL tutorial videos on youtube. You'll probably find many that are more useful than lectures themselves. I think Khan Academy has videos on SQL, if so then by all means watch them.
 

1. You are in the SEO section, maybe the wrong one for such a question.
2. Let's see, your task is to write SQL STATEMENTS (plural of Statement) to insert these data. Here is the solution for that:

Code:
INSERT INTO PET_OWNER(OwnerLastName, OwnerFirstName, OwnerPhone, OwnerEmail) VALUES('Downs', 'Marsha', '555-537-8765', '[email protected]');
INSERT INTO PET_OWNER(OwnerLastName, OwnerFirstName, OwnerPhone, OwnerEmail) VALUES('James', 'Richard', '555-537-7654', '[email protected]');
INSERT INTO PET_OWNER(OwnerLastName, OwnerFirstName, OwnerPhone, OwnerEmail) VALUES('Frier', 'Liz', '555-537-6543', '[email protected]');
INSERT INTO PET_OWNER(OwnerLastName, OwnerFirstName, OwnerEmail) VALUES('Trent', 'Miles', '[email protected]');

And why? Okay... the task already tells you which query you should use: "insert these data"... so it needs to be INSERT INTO statements. The ID is the Primary Key with an auto increment, so that we don't have to add by hand (It just counts up the ID for each inserted row). On the last guy there is no Phone Number, so we leave that out too (As it matchs the default value).
 
Last edited:
Here is the next question:

https://gyazo.com/1fe1fd33c5b13767eb294e5942acb92f

He is telling you not to put a foreign key constraint on the pet table. So basically, he is saying to put a primary key on petid but don't make ownerID a foreign key.
 
Back
Top