Posts

Showing posts with the label Query all columns for a city in CITY with the ID 1661.

Query all columns for a city in CITY with the ID 1661.

Image
The  CITY  table is described as follows: THEORY: What is a SELECT Statement? The SELECT statement is used to retrieve data from one or more tables in a database. It is the most commonly used command in SQL (Structured Query Language). Types of SELECT Queries Simple SELECT SELECT * FROM customers; SELECT with WHERE SELECT name FROM customers WHERE country = 'USA' ; SELECT with Aggregates SELECT COUNT ( * ) FROM orders; SELECT with JOIN SELECT orders.id, customers.name FROM orders JOIN customers ON orders.customer_id = customers.id; SELECT with Subquery SELECT name FROM customers WHERE id IN ( SELECT customer_id FROM orders WHERE amount > 1000 ); 🔹 Important Notes SQL is not case-sensitive , but common practice is to write keywords in UPPERCASE . You can alias columns and tables for readability: SELECT name AS customer_name FROM customers; SOLUTION: SELECT * FROM CITY WHERE ID='1661';