Selectia

postat acum 4 ani de Stefanescu Mihai in categorie SQL

Comanda SELECT este folosita pentru a afisa informatiile stocate intr-un tabel dintr-o baza de date. Acest rezultat returnat se numeste set de rezultate (result-set).

SELECT Coloana1, Coloana2, ColoanaN FROM numeTabel;

In exemplul de mai sus vor fi afisate decat valorile coloanelor trecute in select. Daca doriti sa afisati toate datele din tabel folositi urmatoarea sintaxa:

SELECT * FROM numeTabel;

Exemplu

Presupunem ca avem urmatorul tabel angajati cu aceste informatii:

+----+----------+--------+--------------+-----------+
| ID | NUME     | VARSTA | ADRESA       | SALARIU   |
+----+----------+--------+--------------+-----------+
|  1 | Mihai    |    22  | Bucuresti    | 10000.00  |
|  2 | Alex     |    25  | Pitesti      |  1500.00  |
|  3 | George   |    23  | Cluj         |  2000.00  |
|  4 | Mircea   |    25  | Iasi         |  6500.00  |
+----+----------+--------+--------------+-----------+

Mai jos am scris o interogare ce va selecta decat coloanele ID, Nume si Salariu din tabelul angajati:

SELECT ID, NUME, SALARIU FROM angajati

Acest cod va avea urmatorul rezultat:

+----+----------+-----------+
| ID | NUME     |  SALARIU  |
+----+----------+-----------+
|  1 | Mihai    | 10000.00  |
|  2 | Alex     |  1500.00  |
|  3 | George   |  2000.00  |
|  4 | Mircea   |  6500.00  |
+----+----------+-----------+

Daca doriti sa selctati toate coloanele din tabelul angajati folositi urmatoarea interogare:

SELECT * FROM angajati;

 

Sunt un tanar programator din Bucuresti ce lucreaza in PHP/Mysql (MySqli/PDO), Laravel, CodeIgniter, MySQL, PostgreSQL, Wordpress, HTML5/CSS3, Sass, Photoshop si multe altele.
Google+ Community Facebook Group
Acest articol a fost mutat de pe vechea platforma.
Pentru orice eroare aparuta la mutare va rog sa ma contactati!

Comentariu postate de free minecraft download la data de 15.05.2019
I loved as much as you will receive carried out right here. The sketch is tasteful, your authored material stylish. nonetheless, you command get got an impatience over that you wish be delivering the following. unwell unquestionably come more formerly again since exactly the same nearly a lot often inside case you shield this increase.
Comentariu postate de minecraft free download la data de 16.05.2019
Amazing! Its genuinely amazing post, I have got much clear idea on the topic of from this article.
Comentariu postate de minecraft download la data de 16.05.2019
Thanks on your marvelous posting! I quite enjoyed reading it, you will be a great author. I will be sure to bookmark your blog and may come back at some point. I want to encourage you to ultimately continue your great posts, have a nice evening!