SQL Exercises: Display all information about all salespeople
Write a SQL statement that displays all the information about all salespeople.
Sample table: salesman
salesman_id | name | city | commission -------------+------------+----------+------------ 5001 | James Hoog | New York | 0.15 5002 | Nail Knite | Paris | 0.13 5005 | Pit Alex | London | 0.11 5006 | Mc Lyon | Paris | 0.14 5007 | Paul Adam | Rome | 0.13 5003 | Lauson Hen | San Jose | 0.12
Sample Solution:
SQL Code:
-- This query selects all columns from the 'salesman' table.
SELECT *
-- Specifies the table from which to retrieve the data (in this case, 'salesman').
FROM salesman;
Output of the Query:
salesman_id name city commission 5001 James Hoog New York 0.15 5002 Nail Knite Paris 0.13 5005 Pit Alex London 0.11 5006 Mc Lyon Paris 0.14 5007 Paul Adam Rome 0.13 5003 Lauson Hen San Jose 0.12
Code Explanation:
The said query in SQL that selects all columns from the table 'salesman'. It returns all the rows and columns of the table salesman.
SQL syntax:
SELECT [DISTINCT] [<qualifier>.]<column_name> |*| <expression> [AS <column_alias>],... FROM <table_or_view_name> | <inline_view> [[AS] <table_alias>] [WHERE <predicate>] [GROUP BY [<qualifier>.]<column_name>,... [HAVING <predicate>] ] [ORDER_BY <column_name> | <column_number> [ASC | DESC],... ];
Note: Use * to get a complete list of the columns from a table.
Alternate command:
SELECT salesman_id, name, city, commission

Visual presentation:

Practice Online
For more Practice: Solve these Related Problems:
- Write a SQL query to display all the information about all customers.
- Write a SQL query to retrieve all details of products from a table named "products".
- Write a SQL query to list all employees from the "employees" table.
- Write a SQL query to fetch all records from a table named "suppliers".
Have another way to solve this solution? Contribute your code (and comments) through Disqus.
Previous SQL Exercise: SQL Retrieve data from tables Exercises Home
Next SQL Exercise: Display a given string.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- Weekly Trends and Language Statistics
- Weekly Trends and Language Statistics