Perform selection and deletion at the same time


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Perform selection and deletion at the same time
# 1  
Old 10-28-2007
Perform selection and deletion at the same time

I am performing some operation like:

SQL Statement below:

Code:
UPDATE table2 SET column1_table2 = ( SELECT column1_table1
FROM table1 WHERE column2_table1 = column2_table2 LIMIT 1)
LIMIT 2;


So what I'm trying to do is to find a corresponding value and then I'm adding it into table2. Now how can I actually delete this value after this has been added to table2 immediately?
# 2  
Old 10-28-2007
Quote:
Originally Posted by Legend986
I am performing some operation like:

SQL Statement below:

Code:
UPDATE table2 SET column1_table2 = ( SELECT column1_table1
FROM table1 WHERE column2_table1 = column2_table2 LIMIT 1)
LIMIT 2;


So what I'm trying to do is to find a corresponding value and then I'm adding it into table2. Now how can I actually delete this value after this has been added to table2 immediately?

I could see that only a value is updated in the table and not deleted.
Is that you are interested in doing updation and deletion simultaneously ?

and by deleting a value ==> its only a record that can be deleted and not the column alone.
# 3  
Old 10-28-2007
Yeah... For example.. consider the instance when we execute the statement and it iterates to find records that match the criteria... the output changes from:
Code:
Table 1:
121::::ABCDE::::::0.2
230:::::ASDS:::::::0.6
xxx::::::jaksd:::::::0.7
xxx::::::dasdd:::::::0.3
xxx::::::asaaa:::::::0.1
xxx::::::ddddd:::::::0.5

Table 2:
121::::ABCDE
230:::::ASDS
343::::::jaksd
545::::::dasdd
656::::::asaaa
344::::::ddddd

to

Quote:
Table 1:
121::::ABCDE::::::0.2
230:::::ASDS:::::::0.6
343::::::jaksd:::::::0.7
xxx::::::dasdd:::::::0.3
xxx::::::asaaa:::::::0.1
xxx::::::ddddd:::::::0.5

Table 2:
121::::ABCDE
230:::::ASDS
343::::::jaksd
545::::::dasdd
656::::::asaaa
344::::::ddddd
There's a change right? Thats the only thing I want... It'll search for the string in Table_2, fetch the corresponding value and then update the same in Table1. I don't know the internal workings of SQL but what I was thinking was that if I delete the record which was just checked from Table_2, i can actually speed up the process of updating because it would then have to check less records each time it is checking.... Correct me if I'm wrong please... And the context in which I'm talking has some million records and thus I'm searching for a good way to speed up things...
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Selection from array

Hi, I need some help taking a selection from a command and adding part of the output to an array. I'd like to read the items into the array, have the user chose an option from the array and put the item from column 1 into a variable. The command is: awless -l list routetables --columns... (7 Replies)
Discussion started by: bignellrp
7 Replies

2. Shell Programming and Scripting

Selection of records y time and offset.

Gents, I have an csv file which contends value GPS time for each record and x, y coordinates.. The purpose is to identify which vps does not match with the law parameters in the relation time and offset. In the graphic attached you can see example of 3 vps which are showed in red color and... (12 Replies)
Discussion started by: jiam912
12 Replies

3. Shell Programming and Scripting

Output selection with EOF

I have a script: #!/bin/ksh runmqsc CERN.PROD <<EOF dis chs(to.*) end EOF which gives me the output as: 1 : dis chs(to.*) AMQ8417: Display Channel Status details. CHANNEL(TO.CGPRODAPP2) CHLTYPE(CLUSRCVR) CONNAME(10.60.16.50) CURRENT ... (5 Replies)
Discussion started by: Daniel Gate
5 Replies

4. Shell Programming and Scripting

If Selection statement

ok im kinda stuck i have a bash script with 4 options 1. Create Script 2. Show Script 3 . Delete script 4. Exithow would i use an if statement for this? im not sure what test command i would use. I know it would be like this (below) to display the script if then cat script1or for the... (10 Replies)
Discussion started by: gangsta
10 Replies

5. Shell Programming and Scripting

Date selection

Hi All, i have log file sample data is 2010/10/09|04:00:00.392|15Minute|BW=0|192.168.0.1 2010/10/08|04:00:00.392|15Minute|BW=0|192.168.0.1 2010/10/07|04:00:00.392|15Minute|BW=0|192.168.0.1 2010/10/05|04:00:00.392|15Minute|BW=0|192.168.0.1 2010/10/03|04:00:00.392|15Minute|BW=0|192.168.0.1... (2 Replies)
Discussion started by: posner
2 Replies

6. Shell Programming and Scripting

Data selection

Hi, Please note that as a programmer I cannot tell the file format or details of my production files so I have re-framed my file and taken a case of departments. Kindly guide as its related to a production requirement of data containing recors of production customer NOT A HOMEWORK :) I have... (10 Replies)
Discussion started by: test_user
10 Replies

7. Shell Programming and Scripting

Data selection

Hi, I have a file containing details of different departments . Infomration of departments is in various tags file is as below I want to create a new file from the above file which should contain only two fields belonging to one department format There are multiple files... (1 Reply)
Discussion started by: test_user
1 Replies

8. Post Here to Contact Site Administrators and Moderators

Opt out selection

Maybe I'm missing something but when I go to CP->Options, I see the box for selecting which forum to opt out of but no way to set it. (5 Replies)
Discussion started by: drhowarddrfine
5 Replies

9. UNIX for Advanced & Expert Users

tray selection

Hello All, Could anyone help me how to selecting the trays in unix . Thanks, Amit kul (3 Replies)
Discussion started by: amit kul
3 Replies

10. Shell Programming and Scripting

Array and Selection

I have a question: Y X Tabel a is a array multidimensional --> a(1024,20) I load in to array a Text from 6000 row where: in a(1,1) is present the row 1 of original text, in a(1024,1) is present then row 1024 of original test and in... (4 Replies)
Discussion started by: ZINGARO
4 Replies
Login or Register to Ask a Question