SQL Reference

Quick Reference

The EXISTS keyword tests for the existence of any record in a subquery, and returns “true” if the subquery returns one or more records.

The following lists the suppliers with a product price less than 50.

SELECT order_number
FROM Orders
WHERE EXISTS (SELECT product_name FROM Products WHERE order_id = order_number.order_id AND price < 50);

SQL Notes:

  • Any work being done to modify the structure of a database or delete tables or the the database itself should only be done after making a recent backup

We’d like to acknowledge that we learned a great deal of our coding from W3Schools and TutorialsPoint, borrowing heavily from their teaching process and excellent code examples. We highly recommend both sites to deepen your experience, and further your coding journey. We’re just hitting the basics here at 1SMARTchicken.