1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Help with SQL

Discussion in 'White Hat SEO' started by BTCWorker, Sep 30, 2015.

  1. BTCWorker

    BTCWorker Registered Member

    Joined:
    Apr 8, 2015
    Messages:
    68
    Likes Received:
    3
    Occupation:
    Freelancer - eCommerce - Marketing
    Location:
    Daytona Beach, Florida, U
    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.
     
  2. fidodido

    fidodido Junior Member

    Joined:
    Aug 12, 2015
    Messages:
    113
    Likes Received:
    27
    Your UPDATE would be a INSERT INTO there

    You insert data with INSERT, you update data with UPDATE
     
  3. BTCWorker

    BTCWorker Registered Member

    Joined:
    Apr 8, 2015
    Messages:
    68
    Likes Received:
    3
    Occupation:
    Freelancer - eCommerce - Marketing
    Location:
    Daytona Beach, Florida, U
    I tried INSERT and it tells me that I am trying to insert a duplicate entry for "ID #4"
     
  4. fidodido

    fidodido Junior Member

    Joined:
    Aug 12, 2015
    Messages:
    113
    Likes Received:
    27
    Yeah because the record it is probably already there in that table?
     
  5. BTCWorker

    BTCWorker Registered Member

    Joined:
    Apr 8, 2015
    Messages:
    68
    Likes Received:
    3
    Occupation:
    Freelancer - eCommerce - Marketing
    Location:
    Daytona Beach, Florida, U
    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...
     
  6. BTCWorker

    BTCWorker Registered Member

    Joined:
    Apr 8, 2015
    Messages:
    68
    Likes Received:
    3
    Occupation:
    Freelancer - eCommerce - Marketing
    Location:
    Daytona Beach, Florida, U
    Here is the next question:

    Screen
     
  7. fidodido

    fidodido Junior Member

    Joined:
    Aug 12, 2015
    Messages:
    113
    Likes Received:
    27
    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
     
  8. BTCWorker

    BTCWorker Registered Member

    Joined:
    Apr 8, 2015
    Messages:
    68
    Likes Received:
    3
    Occupation:
    Freelancer - eCommerce - Marketing
    Location:
    Daytona Beach, Florida, U
    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
     
  9. accelerator_dd

    accelerator_dd Jr. VIP Jr. VIP

    Joined:
    May 14, 2010
    Messages:
    2,448
    Likes Received:
    1,010
    Occupation:
    SEO
    Location:
    IM Wonderland
    You should be doing it with an INSERT. However, the ID (OwnerID) is autogenerated, ignore it, dont mention it in the fields or values.
     
  10. bartosimpsonio

    bartosimpsonio Jr. VIP Jr. VIP Premium Member

    Joined:
    Mar 21, 2013
    Messages:
    12,751
    Likes Received:
    11,417
    Occupation:
    COINZ
    Location:
    BUYAH
    Home Page:
    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.
     
  11. AdludumAndre

    AdludumAndre Registered Member

    Joined:
    Mar 21, 2015
    Messages:
    51
    Likes Received:
    8
    Occupation:
    CTO & Co-Founder of Adludum.com
    Location:
    Germany
    Home Page:
    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: Sep 30, 2015
  12. archon10

    archon10 BANNED BANNED

    Joined:
    Oct 10, 2011
    Messages:
    1,181
    Likes Received:
    8,223
    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.