Execution procedure stockée sur un select
thiouraye
Messages postés
7
Date d'inscription
Statut
Membre
Dernière intervention
-
thiouraye Messages postés 7 Date d'inscription Statut Membre Dernière intervention -
thiouraye Messages postés 7 Date d'inscription Statut Membre Dernière intervention -
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
- Procédure de frigo vide - Forum Vos droits sur internet
- Reboot and select proper boot device asus - Forum Matériel & Système
- Le point d'entrée de procédure eventsetinformation est introuvable advapi32.dll - Forum Windows
- Please select boot device - Forum Windows 7
- Arnaque transcash sur Leboncoin. ✓ - Forum Consommation & Internet
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