Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SELECT * FROM table WHERE id IN (array)

Status
Not open for further replies.

kolorasta

Technical User
Jul 2, 2002
65
AR
the subject is an introduction of what i want...

i wanto to obtain some records from a table where the column value is in a group of values, asorted values...

example:
id,value
1,Martin
2,Omar
3,Pedro
4,Andrea
5,Paola
6,Romina
7,Julieta
8,Yari

I want to obtain the rows where id=1,6,3

one way to do this is:
SELECT * FROM tablename WHERE (id=1) OR (id=6) OR (id=3)

I want to know if there is a simplier and a more flexible way to do that... for example:
SELECT * FROM tablename WHERE (id IN (1,6,3))
(note: the above sintax if invented, i don't know if it is valid or not)

greetz...
Kolo

PS: sorry for my poor english
 



Yes...
Code:
...
Where id In (1, 3, 6)


Skip,

[glasses] [red]Be advised:[/red]To be safe on the FOURTH, don't take a FIFTH on the THIRD, or...
You might not come FORTH on the FIFTH! [bomb][tongue]
 
ok... now i´ve got some other problems with this issue.

i´ve got a FORM... this from call a REPORT and this report has a SUBREPORT

the SUBREPORT has the Select ....Where id IN (array)


I call the REPORT and passes some parameters and I recive them in the report by the "OpenArgs" variable.
the report name is [Factura B compuesta] ...
so I have this sql sentence in the Record Source field in the subreport.
SELECT....
WHERE (((deudas.id) In (Forms![Factura B compuesta].OpenArgs)) AND ((deudas.cancelada)=False));


Now the question is... how do I have to pass the parameters in the OpenArgs variable??? the syntax...
y tried these and they didn´t work
(4,2,5)
(4;2;5)
4,2,5
4;2;5
"(4,2,5)"
etc...

if I pass only one parametre it works...
for example: (4)

but it doesn't work with more than one parameter

any help will be appreciated

sorry for my poor english
 

K,

Please post this new question in a NEW thread.

I know that a parameter query in MS Query does not work with the IN operator. YOu may need to revert to the OR operator
Code:
WHERE (id=?) OR (id=?) OR (id=?)

Skip,

[glasses] [red]Be advised:[/red]We know Newton's 3 Laws. But did you hear about the [red]FOURTH???[/red]
Only ONE fig per cookie![tongue]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top