Git Product home page Git Product logo

dsc-database-admin-101-lab's Issues

Database Admin 101 lab solution Issue

Link to Canvas

https://learning.flatironschool.com/courses/5329/assignments/187391?module_item_id=417321

Issue Subtype

  • Master branch code
  • [ x] Solution branch code
  • Code tests
  • Layout/rendering issue
  • Instructions unclear
  • Other (explain below)

Describe the Issue

Source

# Delete the duplicate entry
cur.execute("""DELETE FROM contactInfo 
               WHERE telephone = 3259909290;""")

Concern

The goal for this snippit of code is to delete a duplicate entry, but the solution deletes all entries.

(Optional) Proposed Solution

cur.execute("""SELECT firstName, lastName, telephone, COUNT()
FROM contactInfo
GROUP BY firstName, lastName, telephone
HAVING COUNT(
) > 1;""").fetchall()

cur.execute("""SELECT userID
FROM contactInfo
WHERE tel_num = 3259909290;""").fetchall()

cur.execute("""DELETE FROM contactInfo
WHERE userID = 6""")

The code finding the duplicate entry can still be used. Then using the telephone number find the primary keys of all the entries containing that number. Using the primary key delete the duplicate. In the case of this example the primary keys were 5 and 6. Code can be adjusted if there are multiple duplicate entries by changing the operator to > lowest_userID.

What OS Are You Using?

  • OS X
  • [X ] Windows
  • WSL
  • Linux
  • IllumiDesk

Any Additional Context?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.