| 12
 3
 4
 5
 6
 7
 8
 9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 
 | create table T1
      (  T1ident     integer      not null  primary key
       , T1matricule char(08)     not null  unique
       , T1nom       varchar(40)  not null
       , T1prenom    varchar(40)  not null
       , T1date      date         not null
      )
;
insert into T1 (T1ident, T1matricule, T1nom, T1prenom, T1date)
values (0001, '10140008', 'Dupont', 'Martine', '2016-04-20')
     , (0002, '15508077', 'Martin', 'Jean', '2022-11-05')
     , (0003, '20016663', 'Ledu', 'Solène', '2024-01-06')
;
set @col = 'nom'     ;
set @val = 'Martin'  ;
 
select T1ident
     , T1matricule
     , T1nom
     , T1prenom
     , T1date
from T1
where case when @col = 'matricule' and T1matricule=@val then 1
           when @col = 'nom'       and T1nom=@val       then 1
           when @col = 'prenom'    and T1prenom=@val    then 1
      end = 1 | 
Partager