GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing www.geeksforgeeks.org — SQL SELECT Query (With Examples) - GeeksforGeeks SQL SELECT QueryLast Updated : 21 Aug, 2026 The SQL SELECT statement is used to retrieve data from one or more tables and display it in a structured format of rows and columns.
Example: First, we create a demo SQL table, on which we use the SELECT query. ![]() Query: SELECT customers_id, first_name Output: ![]() SyntaxSELECT column1,column2....
WorkingThe SELECT statement is used to retrieve and display data from one or more tables in a structured and readable format. Example 1: Select Specific ColumnsIn this example, we will demonstrate how to retrieve specific columns from the customerss table. Here we will fetch only first_name and last_name for each record. Query: SELECT first_name, last_name Output: ![]() Example 2: Select All ColumnsIn this example, we will fetch all the fields from table customerss: Query: SELECT * FROM customers;Output: ![]() Example 3: SELECT Statement with WHERE ClauseSuppose we want to see table values with specific conditions then WHERE Clause is used with select statement. In this example, filter customers who are 21 years old. Query: SELECT first_name Output: ![]() Example 4: SELECT with GROUP BY ClauseIn this example, we will use SELECT statement with GROUP BY Clause to group rows and perform aggregation. Here, we will count the number of customers from each country. Query: SELECT country, COUNT(*) AS customer_count Output: ![]() Example 5: SELECT with DISTINCT ClauseIn this example, we will use DISTINCT keyword to return only unique values from a column. Here, we will fetch unique countries from the customers table. Query: SELECT DISTINCT country Output: ![]() Example 6: SELECT Statement with HAVING ClauseThe HAVING clause is used to filter results after applying GROUP BY. In this example, we will find countries that have 2 or more customers in the customers table. Query: SELECT country, COUNT(*) AS customer_count Output: ![]() Example 7: SELECT Statement with ORDER BY clauseIn this example, we will use SELECT Statement with ORDER BY clause. Here, Sort results by Age in descending order. Query: SELECT * Output: ![]() Example 8: SELECT Statement with LIMIT clauseIn this example, we will use SELECT Statement with LIMIT clause Query: SELECT * FROM customers Output: ![]() Comment ExploreData Constraints & Aggregate Functions |
| You are visitor 01402503 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |