AgerNic.com/ro
WEB DEVELOPER SITE, HTML, CSS, PHP, SQL
Tutorial

Instruc?iunea SQL SELECT


<< Previous Page
sintaxa SQL
Next Page >>
sintaxa SQL

SQL Tutorial » Instruc?iunea SQL SELECT

Ce este instructiunea SELECT * in SQL?

Instruc?iunea SELECT in SQL este utilizat? pentru a selecta date dintr-o anumita baz? de date.

Datele returnate sunt stocate într-un tabel cu rezultate, denumit setul de rezultate.

Sintaxa SQL SELECT Statement:

SSELECT coloana1, coloana2, ...
FROM nume_tabel;

 

Dac? dori?i s? selecta?i toate câmpurile disponibile dintr-un tabel, trebuie sa utiliza?i urm?toarea sintax?:

Sintaxa:

SELECT * FROM nume_tabel;

In exemplul de mai jos avem o selec?ie din tabelul „Clien?i” dintr-o baza de date, ca exemplu Test_clienti:

ID Prenume Nume Tara Oras Produs ID Cantitatea
1 Clark Kent USA Miami 24 11
2 Pire Joveau France Paris 56 32
3 Cristian Andone Romania Brasov 67 9
4 Pepe Martínez Spain Madrid 112 26
5 Peter Parker SUA Los Angeles 19 41

 

SQL SELECT

Va aratam un exemplu in care instruc?iune SQL SELECT selecteaza toate tarile (inclusiv duplicatele) din coloana „?ar?” din tabelul „Test_clien?i”:

SELECT Tara FROM Test_clien?i;

Rezultatul: Num?r de înregistr?ri: 5

ID Tara
1 USA
2 France
3 Romania
4 Spain
5 SUA

 

Related subjects:
Sintaxa SQL Select data from database Insert data into SQL Display data from SQL

 

Tags: sql select în tabel, select distinct, din mai multe tabele, select ultimul rând, primul, valori, baz? de date, distinct, top
Ce este SELECT * în SQL?
Cum SELECTez un câmp de date în SQL?
Ce este o list? SELECT SQL?
Cum SELECTez anumite rânduri în SQL?

 

SQL SELECT DISTINCT Exemple

Urm?toarea instruc?iune "SELECT DISTINCT" SQL selecteaz? doar valorile distincte din coloana „?ar?” din tabelul „Test_clien?i”:

SELECT DISTINCT Tara FROM Test_clien?i;

Rezultatul: Num?r de înregistr?ri: 4

ID Tara
1 USA
2 France
3 Romania
4 Spain

 

Urmatorul exemplu listeaz? num?rul de ??ri diferite (distinte) din tabelul „Test_clien?i”:

SELECT COUNT(DISTINCT Tara) FROM Test_clien?i;

Rezultatul: Num?r de înregistr?ri: 3

ID Tara
2 France
3 Romania
4 Spain

 

Exemplu SELECT Coloane

Urm?toarea instruc?iune SQL selecteaz? coloanele „ID”, "Prenume", "Nume" din tabelul „Test_clien?i”:

SELECT ID, Prenume, Nume FROM Test_clien?i;

 

ID Prenume Nume
1 Clark Kent
2 Pire Joveau
3 Cristian Andone
4 Pepe Martínez
5 Peter Parker

 

Urm?toarea instruc?iune SQL selecteaz? toate coloanele din tabelul "Test_clien?i":

SELECT * FROM Test_clien?i;
Tags: sql select în tabel, select distinct, din mai multe tabele, select ultimul rând, primul, valori, baz? de date, distinct, top
Ce este SELECT * în SQL?
Cum SELECTez un câmp de date în SQL?
Ce este o list? SELECT SQL?
Cum SELECTez anumite rânduri în SQL?


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.


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.


analytics piwika