AgerNic.com
WEB DEVELOPER SITE, HTML, CSS, PHP, SQL

SQL SELECT Statement


<< Previous Page
SQL tutorial
Next Page >>
SQL tutorial

SQL Tutorial » SQL SELECT Statement

What is SELECT * from in SQL?

SQL SELECT statement is used to select any data from a database.
The data returned (displayed) is stored in a result table, called the result-set.

Syntax:

SELECT column_name1, column_name2, ...
FROM table_name;

column_name1, column_name2, ... are the field names of the table_name you want to select data from.
To select all the fields available in the table_name, you have to use the following syntax:

SELECT * FROM table_name;

Let's look at the "Order_details" table: We will have seven columns as: "id", "first_name", "last_name", "country", "city", "product_id"and "quantity":

ID First Name Last Name Country City Product ID Quantity
1 Clark Kent USA Miami 24 11
2 Pire Joveau France Paris 56 32
3 Nicky Anderson   Boston 67 9
4 Pepe Martínez Spain Madrid 112 26
5 Peter Parker SUA Los Angeles 19 41

 

How do I SELECT specific rows in SQL? Example

Let's look at the "Order_details" table: We will have seven columns as: "id", "first_name", "last_name", "country", "city", "product_id"and "quantity":

The following SQL statement selects the "CustomerName" and "City" columns from the "Customers" table:

SELECT first_name, last_name FROM Order_details;

Display out: Number of Records: 5

ID First Name Last Name
1 Clark Kent
2 Pire Joveau
3 Nicky Anderson
4 Pepe Martínez
5 Peter Parker

Related subjects:
SQL order by SQL where clause PHP select / view data Conect to MySQLi SQL insert into table

Tags: sql select: from multiple tables, as, synrax, distinct, count, group by, sort, top, like, into
What is SELECT * from in SQL?
What is a SELECT list SQL?
How do I SELECT specific rows in SQL?
How do you query in SQL?

 

SQL SELECT statement all columns from table

The following SQL SELECT statement all the columns from the "Order_details" table:

SELECT * FROM Order_details;

 

ID First Name Last Name Country City Product ID Quantity
1 Clark Kent USA Miami 24 11
2 Pire Joveau France Paris 56 32
3 Nicky Anderson   Boston 67 9
4 Pepe Martínez Spain Madrid 112 26
5 Peter Parker SUA Los Angeles 19 41

 

How do you SELECT multiple tables in a query?

How do you SELECT multiple tables in a query?
How can I get data from three tables in a single query?

We have three database as: country, products, customer

SELECT country.country_name, products.product_name, customer.customer_name
FROM country
INNER JOIN products ON product.country_id = country.id
INNER JOIN customer ON customer.product_id = product.id;

 



sql select: from multiple tables, as, synrax, distinct, count, group by, sort, top, like, into
What is SELECT * from in SQL?
What is a SELECT list SQL?
How do I SELECT specific rows in SQL?
How do you query in SQL?

SQL SELECT Statement - sql tutorial

Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


Home - Database
SQL - Database
SQL Syntax
SQL Select Data
SQL Insert Data
SQL Update
SQL Delete Row
PHP mysqli_query()
SQL order
SQL Create Database
SQL Display Data
SQL Count()
SQL mysqli_connect
SQL create table
SQL Where And & Or
SQL like Syntax
SQL Between Operator
SQL IN Operator
Online Editor
ONLINE EDITOR

news templates


COLOR PICKER

news templates
This tool makes it easy to create, adjust, and experiment with custom colors for the web.


HTML Templates
news templates
Magnews2 is a modern and creative free magazine and news website template that will help you kick off your online project in style.


CSS HTML Layout
news templates
Find here examples of creative and unique website layouts.


Free CSS HTML Menu
news templates
Find here examples of creative and unique website CSS HTML menu.


Create a Sticky Navbar with and without ...
CSS Grid Layout. Examples of grid-gap, l...
CSS animation examples: delay, rotate, s...
CSS font weight bold, thin, values, semi...
CSS background color - opacity, gradient...
CSS flex - display: flex - CSS Flexbox L...
CSS border padding...
HTML text center horizontally and vertic...
HTML text input <input type="text"&g...
HTML link color...
How to Link CSS to HTML, external file n...
HTML link - hyperlink...
jQuery replace...
jQuery replaceClass...
jQuery click ()...
jQuery switchClass()...
jQuery draggable()...
jQuery HTML...
jQuery scroll smooth...
jQuery scroll()...