Skip to Main Content

SQL & PL/SQL

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Selecting rows with specific IDs

519348Jan 31 2007 — edited Jan 31 2007
Hi all. I need help with the following problem.
I have some ID numbers and I have to select the rows which contain these ID numbers (ID is the primary key column in my table). For example my table might look like this:

ID ...(other columns)
1
2
5
7
..

How can I select the rows which have the specified ID numbers in "ID" column?
Are there any well-known solutions to my problem? I understand that it is simple to write a SELECT like this

select *
from MyTable
where ID in (2,5,7)


But the IDs are selected by the user and I cannot hardcode them into the SELECT statement. I can edit the text of the select statement (from my Delphi program) or try to use Dynamic SQL. But I'd like to know if there exists a better or just more common solution.
Thank you in advance.
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Feb 28 2007
Added on Jan 31 2007
3 comments
1,782 views