Execution procedure stockée sur un select
thiouraye
Messages postés
7
Statut
Membre
-
thiouraye Messages postés 7 Statut Membre -
thiouraye Messages postés 7 Statut Membre -
Bonjour,
je souhaiterais recupérer l'identifiant d'un login. je cherche d'abords sur ma 1ere table s'il n'existe pas je cherche sur la 2eme et s'il n'existe pas je cherche sur la 3eme. j'exécute la requête mais ça ne marche pas j'aurai besoin d'un coup de main s'il vous plait.
Merci beaucoup
if exists (select top 1 id_1,1 as espace FROM table1 WHERE emailprof = @emailprof and password = @password)
else if exists (select top 1 id_2,2 as espace FROM table2 WHERE email= @password and password = @password)
else if exists (select top 1 id_3,3 as espace from table3 where email= @password and password = @password)
je souhaiterais recupérer l'identifiant d'un login. je cherche d'abords sur ma 1ere table s'il n'existe pas je cherche sur la 2eme et s'il n'existe pas je cherche sur la 3eme. j'exécute la requête mais ça ne marche pas j'aurai besoin d'un coup de main s'il vous plait.
Merci beaucoup
if exists (select top 1 id_1,1 as espace FROM table1 WHERE emailprof = @emailprof and password = @password)
else if exists (select top 1 id_2,2 as espace FROM table2 WHERE email= @password and password = @password)
else if exists (select top 1 id_3,3 as espace from table3 where email= @password and password = @password)
A voir également:
- Execution procedure stockée sur un select
- Reboot and select proper boot device asus - Forum Matériel & Système
- Il permet l’exécution des logiciels applicatifs et gère l’utilisation des ressources matérielles (mémoire, processeur, périphériques). - Forum Windows 10
- Le service spouleur d'impression local n'est pas en cours d'exécution - Guide
- Reboot and select proper boot device - Forum Windows
- Logiciel en cours d'execution ✓ - Forum Logiciels
2 réponses
Si j'ai bien compris c'est un truc comme ça que tu veux. Tu peux créer une fonction
CREATE FUNCTION cherche_id (@emailprof nvarchar (50), @password nvarchar(50))
returns int
as
begin
declare @identifiant int
if ((SELECT count(*) FROM table1 WHERE emailprof = @emailprof and password = @password) >0)
set @identifiant = (SELECT top 1 id_1,1 as espace FROM table1 WHERE emailprof = @emailprof and password = @password)
if ((SELECT count(*) FROM table2 WHERE emailprof = @emailprof and password = @password) >0)
set @identifiant = (SELECT top 1 id_2,2 as espace FROM table2 WHERE emailprof = @emailprof and password = @password)
if ((SELECT count(*) FROM table1 WHERE emailprof = @emailprof and password = @password) >0)
set @identifiant = (SELECT top 1 id_3,3 as espace FROM table3 WHERE emailprof = @emailprof and password = @password)
else
set @identifiant = 0
return @identifiant
end
CREATE FUNCTION cherche_id (@emailprof nvarchar (50), @password nvarchar(50))
returns int
as
begin
declare @identifiant int
if ((SELECT count(*) FROM table1 WHERE emailprof = @emailprof and password = @password) >0)
set @identifiant = (SELECT top 1 id_1,1 as espace FROM table1 WHERE emailprof = @emailprof and password = @password)
if ((SELECT count(*) FROM table2 WHERE emailprof = @emailprof and password = @password) >0)
set @identifiant = (SELECT top 1 id_2,2 as espace FROM table2 WHERE emailprof = @emailprof and password = @password)
if ((SELECT count(*) FROM table1 WHERE emailprof = @emailprof and password = @password) >0)
set @identifiant = (SELECT top 1 id_3,3 as espace FROM table3 WHERE emailprof = @emailprof and password = @password)
else
set @identifiant = 0
return @identifiant
end