Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

Databases

Sobin Sebastian
Sobin Sebastian
5,348 Points

We have an eCommerce database and it has a products table. It has the columns id, name, description and price

We have an eCommerce database and it has a products table. It has the columns id, name, description and price. Delete all products priced at 11 or higher!

2 Answers

Tobias Helmrich
Tobias Helmrich
31,603 Points

Hey Sobin,

to delete all the products priced at 11 or higher you first have to use the keywords DELETE FROM followed by the name of the table, in this case products and the keyword WHERE after which you have to use the greater than or equal operator >= to compare the price to 11.

Like so:

DELETE FROM products WHERE price >= 11

I hope that helps! :)

Jonathan Grieve
Jonathan Grieve
Treehouse Moderator 91,253 Points

It's a delete query is it? Oops, didn't pick up on that :p

Tobias Helmrich
Tobias Helmrich
31,603 Points

Yep! Unfortunately the question wasn't linked to the challenge. It would've been easier to see the task then.

Jonathan Grieve
MOD
Jonathan Grieve
Treehouse Moderator 91,253 Points
SELECT *  FROM products WHERE price => 11;

You want all products of a certain price or higher. So you want to limit the results returned by your query. That's where the the WHERE keyword comes in, You want to return results that match a condition. In this case, prices of 11 or more.

Most of the challenges allow you to use the * keyword to return all the fields.