Save
Save
use TPSQL;
desc COURS;
desc ETUDIANT;
desc ETUDIANT;
use vente;
desc produit;
-- Pour la concaténation
-- En renommant
-- APPLICATION
-- 1 facile
-- 2
select * from clientc where adrc = 'Tunis' and codc mod 1250 = 0;
-- 3
-- 4
select * from produit;
select * from produit where qtes between 500 and 700 and seuil is not null;
-- 5
select * from clientc where nomc like '%ed';
-- 6
select * from produit where lib like '__p%';
-- 7
select * from facture;
select * from facture where datf >= '1999-01-01' and datf <= '1999-12-31';
-- oubien
select * from facture where (year(datf) = 1999);
-- 8
-- 9
-- 10
-- 11
-- 12
select concat('La facture numéro ', numf, ' du client ', codc, ' est de 1000 $')
from facture;
-- APPLICATION
-- 1
select * from clientc where char_length(nomc) > 5;
select repeat('BA',3);
desc clientc;
-- 4
select substring('alpha',2);
select substring('alpha',3);
select substring('alpha',-2);
select substring('alpha',-3);
select substring('alpha',2,2);
select substring('alpha',2,7);
select lower('ALPHAKABA');
select upper('alPHAKABA');
select insert('killa',5,3,'one');
-- APPLICATION
use vente;
-- 1
select * from clientc where char_length(nomc) > 5;
-- 2
-- 3
select * from produit where instr(lib, 'a') = 4 or instr(lib, 'a') = 3 or
instr(lib, 'a') = 7;
-- 4
select adrc from clientc where lpad(adrc, 3, '#') is not null and rpad(adrc, 12,
'*') is not null;
-- 5
-- select * from clientc where trim (trailing ' ' from adrc) is not null;
-- 6
select adrc from clientc where lower(substring(adrc, 1, 1)) is not null and
upper(substring (adrc)) is not null;
-- 7
select * from clientc where upper(adrc) is not null or lower(adrc) is not null;
-- 8
-- select * from clientc where ();
use vente;
-- PRODUIT CARTESIEN
select * from clientc, commande;
-- Jointure
-- Liste des clients qui ont passé des commandes, ainsi que leurs commandes
select * from clientc, commande
where clientc.codc = commande.codc;
-- autre forme
select C.codc, nomc, P.codep, lib, pu from clientc C, commande CM, produit P, pc
where C.codc = CM.codc and CM.numc = pc.numc and pc.codep = P.codep;
-- SEMI JOINTURE