Sep 18, 2002 #1 ivoestg Programmer Mar 21, 2001 77 PT hi, can you tell me if it's possible to know when a result of a select is empty??? i need to do something like that: if (select id from ppl where id =3) not null then <code to make> end if thanks... I'm in ivoestg@yahoo.com
hi, can you tell me if it's possible to know when a result of a select is empty??? i need to do something like that: if (select id from ppl where id =3) not null then <code to make> end if thanks... I'm in ivoestg@yahoo.com
Sep 18, 2002 #2 angiole Programmer Oct 29, 2001 166 CA What's your platform, and what's your purpose. We don't read minds here. AA 8~) Upvote 0 Downvote
Sep 18, 2002 #3 r937 Technical User Jun 30, 2002 8,847 CA with ansi sql, i think you can say select count(*) from (select id from ppl where id =3) if your database doesn't support that, perhaps try the appropriate forum for your database rudy http://rudy.ca/ Upvote 0 Downvote
with ansi sql, i think you can say select count(*) from (select id from ppl where id =3) if your database doesn't support that, perhaps try the appropriate forum for your database rudy http://rudy.ca/
Sep 18, 2002 1 #4 rac2 Programmer Apr 26, 2001 1,871 US If you are using MS SQL Server and you are in a stored procedure the system variable @@ROWCOUNT could be the ticket. For example- Code: SELECT * FROM customers WHERE 1=2 IF @@ROWCOUNT = 0 BEGIN SELECT 'None Found' END But you see it all depends on which DBMS you are using. I wonder, is there an ANSI standard for this? Upvote 0 Downvote
If you are using MS SQL Server and you are in a stored procedure the system variable @@ROWCOUNT could be the ticket. For example- Code: SELECT * FROM customers WHERE 1=2 IF @@ROWCOUNT = 0 BEGIN SELECT 'None Found' END But you see it all depends on which DBMS you are using. I wonder, is there an ANSI standard for this?
Sep 19, 2002 1 #5 adam0101 Programmer Jun 25, 2002 1,952 US If you're writing a stored procedure you can use: Code: if Exists (select id from ppl where id =3) ...some code... else ...some other code... Or you can use: Code: select * from someTable where Exists (select id from ppl where id =3) Upvote 0 Downvote
If you're writing a stored procedure you can use: Code: if Exists (select id from ppl where id =3) ...some code... else ...some other code... Or you can use: Code: select * from someTable where Exists (select id from ppl where id =3)