w3resource
SQL exercises

SQL: Select all the columns from a table

SQL Basic Select Statement : Exercise-1 with Solution

Write a query to display all the columns from salesman table.

Sample table: salesman


Sample Solution :

SELECT * FROM salesman;

Explanation:

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

Syntax of select all the columns from a table

Pictorial presentation :

Result of select all the columns from a table

Query Visualization:

Duration:

Query visualization of Select all the columns from a table - Duration

Rows:

Query visualization of Select all the columns from a table - Rows

Cost:

Query visualization of Select all the columns from a table - Cost

Practice Online


Have another way to solve this solution? Contribute your code (and comments) through Disqus.

Previous: SQL Retrieve data from tables Exercises Home
Next: Write a query to display a string "This is SQL Exercise, Practice and Solution".

What is the difficulty level of this exercise?



New Content: Composer: Dependency manager for PHP, R Programming