Hi...
I need to create a SELECT with a variable in WHERE...
Example:
SELECT * FROM ANSWERS WHERE id = 1
SELECT * FROM ANSWERS WHERE id = 2
... ... ...
It's possible?
Thanks and sorry my english.
Grillo"Guilherme Grillo" <webdev@.rncomtotal.com.br> wrote in message
news:u%23wJB%23iIIHA.748@.TK2MSFTNGP04.phx.gbl...
> I need to create a SELECT with a variable in WHERE...
> Example:
> SELECT * FROM ANSWERS WHERE id = 1
>
> SELECT * FROM ANSWERS WHERE id = 2
Just do both SELECTs at the same time:
SELECT * FROM ANSWERS WHERE id = 1
SELECT * FROM ANSWERS WHERE id = 2
If you're populating a DataSet, it'll have two tables...
If you're populating an SqlDataReader, it'll have two Resultsets - use
MyReader.NextResultset()
http://www.dotnetjohn.com/articles.aspx?articleid=23
Mark Rae
ASP.NET MVP
http://www.markrae.net
If your combined result sets returns too much data then do them separately.
"Mark Rae [MVP]" <mark@.markNOSPAMrae.net> wrote in message
news:uTXyiDjIIHA.484@.TK2MSFTNGP06.phx.gbl...
> "Guilherme Grillo" <webdev@.rncomtotal.com.br> wrote in message
> news:u%23wJB%23iIIHA.748@.TK2MSFTNGP04.phx.gbl...
>
> Just do both SELECTs at the same time:
> SELECT * FROM ANSWERS WHERE id = 1
> SELECT * FROM ANSWERS WHERE id = 2
> If you're populating a DataSet, it'll have two tables...
> If you're populating an SqlDataReader, it'll have two Resultsets - use
> MyReader.NextResultset()
> http://www.dotnetjohn.com/articles.aspx?articleid=23
>
> --
> Mark Rae
> ASP.NET MVP
> http://www.markrae.net
declare @.someId int
set @.someId = 1
select * from categories
where categoryid = @.someId
hope it can help :)
Guilherme Grillo wrote:
> Hi...
> I need to create a SELECT with a variable in WHERE...
> Example:
> SELECT * FROM ANSWERS WHERE id = 1
>
> SELECT * FROM ANSWERS WHERE id = 2
> ... ... ...
> It's possible?
> Thanks and sorry my english.
> Grillo
Subscribe to:
Post Comments (Atom)
0 comments:
Post a Comment