The UNIX and Linux Forums  

Go Back   The UNIX and Linux Forums > Top Forums > Shell Programming and Scripting
Google UNIX.COM


Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here.

More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
How to store the data retrived by a select query into variables? jisha Shell Programming and Scripting 12 01-17-2008 08:45 PM
Doubt regarding Select() sunil_ktg UNIX for Advanced & Expert Users 2 12-15-2007 04:46 AM
Displaying the data from the select query in a particular format sachin.tendulka Shell Programming and Scripting 15 12-11-2007 05:44 AM
Select a portion of file based on query vanand420 Shell Programming and Scripting 14 10-31-2006 01:48 AM
how to select a value randomly norsk hedensk Shell Programming and Scripting 1 10-28-2003 02:39 PM

Reply
 
Submit Tools LinkBack Thread Tools Search this Thread Display Modes
  #1  
Old 02-11-2008
Registered User
 

Join Date: Feb 2008
Posts: 4
Need Help (Select query)

Dear All,
This may sound a simple query but a non technical person like me is not able to do it, So please help me out.
I m using Unix... isql
I jst wanted to do something like following

select * from xyz
where ID= xxxxxxxx (8 digit ID)

Here if i put single 8 digit ID then the query is returning me the details of that particular ID,... Fine... but instead of selecting single ID if i want to select say 100 specific IDs by providing list of IDs then how do i do it?
My email ID is removed email id
Looking forward for ur appreciable help. :-)

Last edited by vino; 02-11-2008 at 11:01 PM.
Reply With Quote
Forum Sponsor
  #2  
Old 02-11-2008
Registered User
 

Join Date: Nov 2007
Posts: 55
hi

do you want to have those 100 ids only or there could be more than that?
Reply With Quote
  #3  
Old 02-11-2008
Registered User
 

Join Date: Jan 2008
Posts: 25
Try this..

May be you can try this..

Solution(1)
=========
(1) Create a temp table with coln : ID
(2) Copy 100 Ids.
If you are using isql, then BCP 100 ids to temp table
(3) Modify the query

select * from
xyz x,
temp t
where x.ID= t.ID

Solution(2)
=========
(1) Use excel spread sheet & paste the 100 Ids
(2) use spread sheet macro & add "," for each ID
Example:

1000,
1001,
1002, and so on

(3) Use the below query..( paste Ids from spread sheet)

select * from xyz
where ID in (
1000,
1001,
1002, -- paste from spread sheet
...
)

Hope above solution helps
Reply With Quote
  #4  
Old 02-12-2008
Registered User
 

Join Date: Feb 2008
Posts: 4
Hey Sathy,
Gr888....Thanx for ur quick reply, I tried last i.e. 3rd solution which is working fine. Also interested in using 1st solution provided by u but not getting how exactly creating a temp table... It would be gr8 help if u explain 1st solution little more.
Thnax.
Reply With Quote
  #5  
Old 02-12-2008
Registered User
 

Join Date: Jan 2008
Posts: 25
Info...as requested

Here are the steps...

(1) creating temp table:
create table temp ( ID int)

(2) BCP data:

bcp DB-name..temp in text.dat -U<userid> -P<password> -c -eERR.dat

;DB-name: Database name
;text.dat: Should contain 100 IDs

After successful BCP, data will be in temp table

(3) Run the query:

select * from
xyz x,
temp t
where x.ID= t.ID
Reply With Quote
  #6  
Old 02-12-2008
Registered User
 

Join Date: Feb 2008
Posts: 4
Hey thanx again for the quick reply.... I tried temp table as well, but some how its not working, may b i m doin somethin wrong... But still i m happy with 2nd n 3rd Solution provided by u...
Thanx once again...
:-) wish u all the best
Reply With Quote
Google The UNIX and Linux Forums
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes




All times are GMT -7. The time now is 06:33 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008. All Rights Reserved.Ad Management by RedTyger Visit The Complex Event Processing Blog

Content Relevant URLs by vBSEO 3.2.0