Delete rows in a table when the columns from two tables match
Hello
I have following two tables.
===========================================
create the table empbooth as
(
Select 1 empid, 1 double cabin Union all the
Select option 2, Union 1 double all the
Select 3, Union 1 double all the
Select option 4, Union 2 double all the
Select option 5, 2 double
);
create the table attsht as
(
Select 1 empid, 240 reg, 0 unpaid all double union
Select option 2, reg 200, 0 unpaid of all the double union
Select 3, 240 reg, 0 unpaid all double them union
Select 4 480 reg, 0 unpaid all double union
Select 5 240 reg, unpaid double 0
);
=================================================
I want to remove rows from attsht where corresponding booth (which is stored in the empbooth table) is 1.
The condition is 'where attsht.empid = empbooth.empid and empbooth.booth = 1 '.
I use oracle 10g.
Help, please
delete from attsht where a.empid in (select b.empid from empbooth b where b.booth = 1)
or
remove from attsht a
where exists (select null
of empbooth b
where b.booth = 1
and b.empid = a.empid)
Tags: Database
Similar Questions
-
The column that does not match when comparing two records
Hi all
We try to compare two tables and find the differences. So if two records (1 of each table) have same PK but not always matching because of some columns, then we would display this columnname. For example:
Table 1
PK Parent Child Property1 Property2 1 A A1 P1 PR1 2 B B1 P2 oraPR2 3 C C1 P3 SRP Table 2
PK Parent Child Property1 Property2 1 A A1 P1 PR1 2 B B1 P2 PR2 3 C C1 P3 PR4 In the above example when I compare 2 tables all matches except Property2 online n ° 3. Thus, we would like to get an output like:
PK Column_Mismatch 3 Property2 (this must be the name of the column that does not match) Appreciate the help.
Thank you
Andy
Hi, Andy.
Andy1484 wrote:
Hi all
We try to compare two tables and find the differences. So if two records (1 of each table) have same PK but not always matching because of some columns, then we would display this columnname. For example:
Table 1
PK Parent Child Property1 Property2 1 A A1 P1 PR1 2 B B1 P2 oraPR2 3 C C1 P3 PR3 Table 2
PK Parent Child Property1 Property2 1 A A1 P1 PR1 2 B B1 P2 PR2 3 C C1 P3 PR4 In the above example when I compare 2 tables all matches except Property2 online n ° 3. Thus, we would like to get an output like:
PK Column_Mismatch 3 Property2 (this must be the name of the column that does not match) Appreciate the help.
Thank you
Andy
Why you don't want no matter what exit for pk = 2? Property2 does not correspond either to pk.
What happens if the 2 columns (or more) do not match? The following query would produce a list delimited, such as ' parents; PROPERTY2 '.
WITH got_mismatch AS
(
SELECT pk
, CASE WHEN t1.parent <> t2.parent THEN '; PARENT' END
|| CASE WHEN t1.child <> t2.child THEN '; CHILD ' END
|| CASE WHEN t1.properry1 <> t2.property1 THEN '; PROPERTY1 ' END
|| CASE WHEN t1.properry2 <> t2.property2 THEN '; PROPERTY2 ' END
AS the offset
FROM table_1 t1
JOIN table_2 t2 ON t2.pk = t1.pk
)
SELECT pk
, SUBSTR (incompatibility, 3) AS column_mismatch
OF got_mismatch
WHERE mismatch IS NOT NULL
;
If you would care to post CREATE TABLE and INSERT statements for your sample data, and then I could test this.
The query above does not count NULL values as inadequate. If you want that, the same basic approach will work, but you can use DECODE instead of <> to compare columns.
What happens if a pk exist in a table, but not the other? You want an outer join, where I used an inner join above.
-
To find common data in 2 columns from two different tables.
Hello
Could someone help me with a querry to discover common data of 2 columns from two different tables?
Thank you
RajeshTry as below.
select col1 ,col2 from tab1 intersect select col1 ,col2 from tab2;
-
Remove the column from the compressed tables
NLSRTL 11.2.0.3.0 Production Oracle Database 11g Enterprise Edition 11.2.0.3.0 64 bit Production PL/SQL 11.2.0.3.0 Production AMT for Linux: 11.2.0.3.0 Production Hello
I read on how to do to remove a compressed table column - first set unused and then drop unused columns. However, in the example below on the basis of data, I ran it, it does not work. Please, can you tell me WHEN this approach does not work. What is dependent on - settings or something else. Why can't I drop unused columns?
And the example and errors:
create table tcompressed compress in select * from all_users;
> TCOMPRESSED table created.
ALTER table tcompressed add x number;
> table TCOMPRESSED altered.
ALTER table tcompressed drop the x column;
>
Error report:
SQL error: ORA-39726: unsupported operation column add/drag on compressed tables
39726 00000 - "operation column add/drop not supported on compressed tables. ''
* Cause: Not support add/column operation move compressed tables
elapse.
* Action: When adding a column, do not specify a default value.
DELETE column is only supported in a column SET UNUSED
(remove the column metadata).
ALTER table tcompressed unused column of the set x;
> table TCOMPRESSED altered.
ALTER table tcompressed drop unused columns;
>
Error report:
SQL error: ORA-39726: unsupported operation column add/drag on compressed tables
39726 00000 - "operation column add/drop not supported on compressed tables. ''
* Cause: Not support add/column operation move compressed tables
elapse.
* Action: When adding a column, do not specify a default value.
DELETE column is only supported in a column SET UNUSED
(remove the column metadata).
As you can see even after changing the table defining the column as unused X I still can't drop by DROP UNUSED COLUMNS.
Thank you.
If you enable compression for all operations on a table, you can delete the columns in the table. If you enable compression for the only direct-path inserts, you can't remove columns.
-
Ideas:
- Outlook 2003
- deleted by mistake the column FRON in the list to the Inbox - how do I get it back?
Here's an example of adding columns to a view Outlook 2003
I hope this helps.
Microsoft® Security MVP, 2004-2009 -
update other items with the same value when when the column contains Y
If you notice the table above which im trying to Edifier is updated the errorred column with 'Y' if the po and invoice are the same and have a 'Y' on the wrong column.CREATE TABLE TEST ( "QUATINTY" NUMBER(17,2), "AMOUNT" NUMBER(17,2), "ERRORRED" VARCHAR2(16 BYTE), "PO" VARCHAR2(12 BYTE), "LINE" VARCHAR2(10 BYTE), "SEQ" VARCHAR2(14 BYTE), "INVOICE" VARCHAR2(16 BYTE) ) Insert into TEST (PO,QUATINTY,AMOUNT,ERRORRED,LINE,SEQ,INVOICE) values ('123',5,50,'Y','1','1','inv1'); Insert into TEST (PO,QUATINTY,AMOUNT,ERRORRED,LINE,SEQ,INVOICE) values ('123',5,50,null,'1','2','inv1'); Insert into TEST (PO,QUATINTY,AMOUNT,ERRORRED,LINE,SEQ,INVOICE) values ('125',5,50,null,'1','1','inv2'); Insert into TEST (PO,QUATINTY,AMOUNT,ERRORRED,LINE,SEQ,INVOICE) values ('125',4,50,null,'1','2','inv2');
in other words, I should finish with "Y" in the column for INV1 errorred.
Can someone point me in the right direction, I can't for the life of me figuered it out.Hello
Here's one way:
UPDATE test SET errorred = 'Y' WHERE NVL (errorred, 'N') != 'Y' AND (po, invoice) IN ( SELECT po, invoice FROM test WHERE errorred = 'Y' ) ;
This requires that the po and invoice are not NULL. If a column can be NULL, then the solution might be a little messier, according to the results you want, but only a little. Post some sample data (with null values) which shows what types of situations, you need manage, and the results of the SAMPLES.
-
Remove the column from the table compress
I try drop column from table DPRUEBA, with compression option:
Any idea?SQL>select * from v$version 2 / BANNER ---------------------------------------------------------------- Oracle Database 10g Enterprise Edition Release 10.2.0.4.0 - 64bi PL/SQL Release 10.2.0.4.0 - Production CORE 10.2.0.4.0 Production TNS for Linux: Version 10.2.0.4.0 - Production NLSRTL Version 10.2.0.4.0 - Production 5 filas seleccionadas. Transcurrido: 00:00:00.09 SQL> SQL>CREATE TABLE DPRUEBA 2 (COL1 NUMBER, 3 COL2 NUMBER) COMPRESS 4 / Tabla creada. Transcurrido: 00:00:00.06 SQL> SQL>ALTER TABLE DPRUEBA DROP COLUMN COL2 2 / ALTER TABLE DPRUEBA DROP COLUMN COL2 * ERROR en línea 1: ORA-39726: operación de agregación/borrado de columnas no soportada en tablas comprimidas Transcurrido: 00:00:00.06
You can always do something like this
SQL> CREATE TABLE DPRUEBA 2 (COL1 NUMBER, 3 COL2 NUMBER) COMPRESS 4 / Table created. SQL> SQL> ALTER TABLE DPRUEBA DROP COLUMN COL2 2 / ALTER TABLE DPRUEBA DROP COLUMN COL2 * ERROR at line 1: ORA-12996: cannot drop system-generated virtual column SQL> SQL> create table new_DPRUEBA 2 as 3 select col1 4 from DPRUEBA 5 / Table created. SQL> SQL> drop table DPRUEBA 2 / Table dropped. SQL> SQL> rename new_DPRUEBA to DPRUEBA 2 / Table renamed. SQL> SQL> desc DPRUEBA Name Null? Type ----------------------------------------- -------- ---------------------- COL1 NUMBER SQL> SQL> SQL> drop table DPRUEBA 2 / Table dropped. SQL> SQL>
Note: you must take care of the constraints and triggers, and others
-
How to avoid the total general of the classic report when the column break is installed in the Apex
Hi all
I develop application using Oracle Apex 4.2.0.
I created the classic report Page.
That I have summarized a column by selecting the check box check sum for the column.
His shows the Grand Total.
Then I chose the columns to break to the first column.
His show the total groupwise and total as well as great as image below.
My requirement is
Need to hide total(Total:)) GroupWise or total general. I need to show any a total, not both.
How to do this?
Thank you
Su.GI
Su.GI wrote:
Hi, thanks for your response.
I use theme - productivity Application - issue 26
-Standard model
Report - report of Standart for classic report model.
The above CSS code where I want to use in the page or report or model region.
Specify a static region ID for the report area and put the following CSS rule in the CSS Inline property page:
#static-region-id .uReportStandard tr:last-child td { display: none; }
where
static-region-id
is the ID specified for the region. -
the column 'from' on my mail has changed all the names being a sender
I get messages from PayPal payment everytime someone pays me. The problem is on one of my email accounts that include all messages from PayPal for payments received from them. Everyone who sent me a payment last week all have the column with name changed to one name instead of that the message was in fact. The column now has only one customer name in it.
For example:
The original message in the column used to say "John doe via Pay Pal"... Now all the messages in the column now say 'jane doe via Pay Pal' when they said originally from john doe. All payments that have been received before and after this specific one payment now all read 'jane doe via Pay Pal' and NOT what they initially said in the column.
I checked with my webmail provided and verified that the e-mail server and e-mail messages are properly formatted on the webmail with the sender correctly displayed in the column. It seems that the problem lies between the web and where it appears in Thunderbird.
Help, please!
Go to your address book and find the entrance to PayPal. Delete the name of this contact. It displays the name of the person where you first saved the contact. No doubt when you have selected to always display content from this sender.
-
I have the data into two table with the structure of similar column, I want to loop through the data in these two tables
based on some condition and runtime that I want to put the query in loop for example, the example is given, please help me
create table ab (a number, b varchar2 (20));
Insert into ab
Select rownum, rownum. "" sample "
of the double
connect by level < = 10
create table bc (a number, b varchar2 (20));
Insert into BC.
Select rownum + 1, rownum + 1 | "" sample "
of the double
connect by level < = 10
declare
l_statement varchar2 (2000);
Boolean bool;
Start
bool: = true;
If it is true, then
l_statement: =' select * ab ';
on the other
l_statement: =' select * from bc';
end if
I'm in execute immediate l_statement - something like that, but I don't know
loop
dbms_output.put_line (i.a);
end loop;
end;
Something like that, but this isn't a peace of the code work.
Try this and adapt according to your needs:
declare
l_statement varchar2 (2000);
c SYS_REFCURSOR;
l_a number;
l_b varchar2 (20);
Boolean bool;
Start
bool: = true;
If it is true, then
l_statement: = "select a, b, AB;
on the other
l_statement: = "select a, b from bc;
end if;
--
Open c for l_statement;
--
loop
extract the c in l_a, l_b;
When the output c % notfound;
dbms_output.put_line (l_a |') -' || l_b);
end loop;
close c;
end;
/
-
Several lines to a format of columns from two tables
Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production
The difficulty to return several lines simple lines/columns in two tables.
Table 1:
ID BOOK_NBR
1 1001
1 2001
2 1010
3 1020
Table 2:
AUTHOR BOOK_NBR
1001 JOHN_1
2001 JOHN_2
MARY 1010
1020 JUNE
Desired output:
ID BOOK_NBR AUTHOR BOOK_NBR AUTHOR
1 1001 JOHN_1 2001 JOHN_2
2 MARY 1010
3-1020 JUNE
There are an unknown number of BOOK_NBR to one ID.
Any guidance would be appreciated.
-
Copy the data from two rows together in a new line
Hello everyone.
I have a question for copying data from two lines together in a new third line.
See this short example:
This is the current situation. The lines STATE_1 and STATE_2 contain different information separate.
In the past data were recorded at random in one of these lines.
It's the state table:
ID Cust_id STATE_1 STATE_2 STATE_3 1 88 Customer is waiting. Call since yesterday. 2 11 Mr. Smith, no answer. Wait until December 3 11 Pls Create PO. Old PO has been cancelled 4 5 No access to the system. Now, everything must be recorded in the STATE_3 void, but I also need than the old entries from the past which must also be copied together in STATE_3
Like this:
ID Cust_id STATE_1 STATE_2 STATE_3 1 88 Customer is waiting. Call since yesterday. Customer is waiting. Call since yesterday 2 11 Mr. Smith, no answer. Wait until December. Mr. Smith, no answer. Wait until December. 3 11 Pls Create PO. Old PO has been cancelled. Pls create in. old PO was canceled. 4 5 No access to the system. No access to the system. Y at - it an SQL-easy order?
Thanks for any help.
What:
update set state_3 = state_1 State | » '|| state_2;
?
-
Lost the video when the transition from XP to Windows 7
After the Upgrade from Windows XP to Windows 7, I lost the video. Upgrade is not completely finished, but I can't do anything to fix the problem I have no display. I need to go back to XP or difficulty somehow the video from the command prompt. What can I do?
How to uninstall Windows 7:
http://support.Microsoft.com/kb/971762How to uninstall Windows 7 by using the Windows.old folder:
http://support.Microsoft.com/kb/971760 -
I currently have a string of the guitar signal electric-Rocksmith Real Tone cable - ASIO 4 all help IK Multimedia Amplitube 3. I would like to know if I could also watch DVD with her while the implementation of the programme of Amplitube with sound. It would be great that I use the DVD for guitar and play at the same time. I don't have the signal of two merged as one. In my mind, I should be able to disable the ASIO devices and use them with DirectX as usual. I could send the ampitube signal to the headphones and use external speakers for the guitar signal, and use the lessons of speakers for the DVD (or maybe YouTube) laptop on board.
Is this possible?
How can I do?
Toshiba Satellite X 205-S7483
Jeff
Yes. For example, I have my Skype phone calls go to my helmet (normal just plugged in the headset) while my media player plays my speakers. You can choose your default communication or multimedia devices with a right click on the volume control icon and choosing "playback devices".
Other programs can also be built to be "to the output current" and allow you to choose the output too.
-
Add lines to and delete rows in a table to the issue of enforcement
I downloaded an example of Adobe for the addition or deletion of a line when running.
The example works fine, but it only allows to generate the maximum of 7 rows!
I tried to change the code but I missed. Can you help me?
Here's the code for the Add button
Form1. #subform [0]. Add::click - (JavaScript, client)
nTableLength stores the number of elements XML contained in table 1.var nTableLength = Table1.nodes.length;
var nNumRow = 0;
for (nCount var = 0; nCount < nTableLength; nCount ++) {}
If ((Table1.nodes.item (nCount) .className == "subform") & (Table1.nodes.item (nCount) .name! == 'HeaderRow')) {}
nNumRow = nNumRow + 1;
}
}If (nNumRow == 7) {}
xfa.host.messageBox ("the maximum number of lines is 7. You cannot add lines more. ","warning ", 3);
}
else {}
Table1.Row1.instanceManager.addInstance (1);
}Take a look at the 'points' field can be defined with a maximum number of lines that illustrated by the subform 'detail', below.
Steve
Maybe you are looking for
-
My game of hearts has suddenly slowed a lot - to slow to play, all the answers?
Cards suddenly are very slow
-
HP pavallion g6-2302ax: Graphics problem back
I have a laptop with a - 4 apu 4300 + graphics card radeon HD which is portable 7670m.this comes with switchable graphics, and since 3 months really gives me problems, no matter which driver do not install switchable. In addition, if I restart window
-
Removal of password for the drive HARD HP 2133
Former emploee returned HP 2133 p/n: FU351EA #AKD s/n:[personal information deleted] and he forgot BIOS password and HARD drive. I have the BIOS reset and cleared BIOS password. Please give me a procedure to remove the HARD drive password. Data from
-
My printer is back online thanks to HP, but the printer will not print, it was printing my e-mails and other things like word. Some web pages, that it would not print. Now, it will print nothing.
-
How to exit safe mode normal mode?
The system starts in SafeMode only. [Transferred from Internet Explorer]