Back to articles
BASIC QUERIES

BASIC QUERIES

via Dev.to BeginnersAbinaya Dhanraj

Query all columns for a city in CITY with the ID 1661. The CITY table is described as follows: Query 1 SELECT * FROM CITY; Explanation: Here I am just getting all the data from the CITY table. SELECT * means all columns and since there is no condition, it shows all rows. Query 2 SELECT * FROM CITY WHERE ID = 1661; Explanation: In this query, I only want the row where ID is 1661. So I used WHERE to filter. SELECT * is used because I need all details of that city. Query 3 SELECT * FROM CITY WHERE CountryCode = 'USA' AND POPULATION > 100000; Explanation: Here I am filtering cities based on two conditions. First, the city should be in USA. Second, population should be more than 100000. Both conditions must be true, so I used AND. * Query 4 SELECT NAME FROM CITY WHERE CountryCode = 'USA' AND POPULATION > 120000; * Explanation: In this case, I only need the city names, not all columns. So I used SELECT NAME. The filtering is same as before but with population greater than 120000. Query 5 SEL

Continue reading on Dev.to Beginners

Opens in a new tab

Read Full Article
7 views

Related Articles