Instructiunile de baza destinate cautarii Flashcards

1
Q

Ce face instructiunea SELECT ?

A

emite rezultatul in format tabelar. Este un fel de System.out.print in java

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

Ce se intampla daca scriem SELECT 2+3; ?

A

Ni se va afisa rezultatul 5

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Cum afisam toate coloanele din tabelul film ?

A

SELECT * from film;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Cum obtinem doar coloanele firstName si lastName din tabelul actor ?

A

SELECT firstName, lastName FROM actor;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Cum putem limita sa ni se afiseze doar primii doi actori introdusi in tabelul actor ?

A

SELECT * FROM actor LIMIT 2;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Cum putem limita sa ni se afiseze doar actorii care au indexul de la nr 8 la 10 ?

A

SELECT * FROM actor LIMIT 8, 2;

practic vor fi sarite primele 8 rezultate si vor fi afisate urmatoarele 2

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Cum putem afla cate randuri contine tabelul actor, fara a afisa toate randurile lucru care este posibil sa incetineasca sistemul ?

A

SELECT SQL_CALC_FOUND_ROWS firstName, lastName FROM actor LIMIT 10;

SELECT FOUND_ROWS();

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Cum ordonam rezultatele din tabelul actor astfel sa fie afisate in ordine alfabetica in functie de firstName de la A-Z?

A

SELECT * FROM actor ORDER BY firstName;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

Cum ordonam rezultatele din tabelul actor astfel sa fie afisate in ordine alfabetica in functie de firstName de la Z-A?

A

SELECT * FROM actor ORDER BY firstName DESC;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

Afisati din tabelul actor doar actorul care are firstName ‘Ion’.

A

SELECT * FROM actor where firstName =’Ion’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Afisati din tabelul actor, toti actorii ale caror firstName incep cu ‘An’

A

SELECT * FROM actor where firstName LIKE ‘an%’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

Afisati din tabelul actor, toti actorii ale caror firstName se termina cu ‘in’

A

SELECT * FROM actor where firstName LIKE ‘%in’:

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

Afisati din tabelul actor, toti actorii ale caror lastName contine urmatoarea secventa de caractere ‘org’

A

SELECT * FROM actor where lastName LIKE ‘%org%’;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Afisati din tabelul film toate titlurile ale caror nume incep cu B si au durata de vizionare mai are de 3 ore

A

SELECT * FROM film where title LIKE ‘B%’ AND length > 180;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

Cum se poate determina numarul de elemente din tabelul film ?

A

SELECT count(film_id) FROM film;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Cum putem afla cati actori cu acelasi firstName exista in tabelul actor ?

A

SELECT count( DISTINCT firstName) FROM actor;