help in registration of the records from two tables
HI: I have two tables joined the first field. The field is the primary key in the first table. Need help listing records from both tables with each a line/record results.create table EVENTS (
event_key varchar2(64) primary key,
event_description varchar2(64),
create_time int
);
create table EVENT_UPDATES (
event_key varchar2(64) NOT NULL ,
update_description varchar2(64),
update_time int
);
insert into EVENTS values('Event1', 'This is event1', 1);
insert into EVENT_UPDATES values('Event1', 'Ticket created', 3);
insert into EVENT_UPDATES values('Event1', 'Event cleared', 10);
insert into EVENTS values('Event2', 'This is event2', 4);
insert into EVENT_UPDATES values('Event2', 'Ticket created', 6);
insert into EVENT_UPDATES values('Event2', 'Event cleared', 8);
I want to print each record in the table of EVENTS such as a line and the corresponding records in EVENT_UPDATES as a line like this recordEvent1 1 This is event1
3 Ticket created
10 Event cleared
Event2 4 This is event2
6 Ticket created
8 Event cleared
TIARavi
select case weight
when 1 then event_key
end key,
time_val,
description
from (
select event_key,
create_time time_val,
event_description description,
1 weight
from events
union all
select event_key,
update_time,
update_description,
2 weight
from event_updates
)
order by event_key,
weight
/
KEY TIME_VAL DESCRIPTION
---------- ---------- -------------------------
Event1 1 This is event1
3 Ticket created
10 Event cleared
Event2 4 This is event2
6 Ticket created
8 Event cleared
6 rows selected.
SQL>
SY.
Tags: Database
Similar Questions
-
Creating records from two Tables at the same time...
I would be very grateful if someone could help with the following query.
I have two Tables, Tbl1 and Tbl2. Tbl1 has the following columns: -.
Tbl1_Unique_ID, Description
Tbl1_Unique_ID is of type ' * number *' and ' * PK * ', Description is of type' * Varchar2 *'.
Tbl2 has the following columns: -.
Tbl2_Unique_ID, Description, Tbl1_Unique_ID
Tbl2_Unique_ID is of type ' * number *' and is the ' * PK * ', Description is of type' * Varchar2 *' and Tbl1_Unique_ID is of type ' * number *', is a ' * foreign key *' and is the ' * primary key *' from Tbl1.
While I can create a page to display and create folders in Tbl1, I'm not course coding required to view and create records Tbl1 and Tbl2 simultaneously, as well as regarding the two together at the same time.
I know that it involves one ' * INSERT *' statement, but I have problems the correct SQL query.
Can anyone provide any assistance will be appreciated.Have you tried to create a form master / detail page? Because it seems that is what you need...
-
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)
-
Help in mandatory query - pulling data from two tables and inserting a
Hi all
I need your help for the modification of the query to get the desired result.
I have two tables A and b. using source Insert and select the command, I need to extract data from tables A and B, then insert and C.
Data and table structures are available below.
Table (Source Table)
Status of payment $
MUL DC 20
ONLY DC 20
ONLY 40 PA
MUL NY 50
Table B (Source Table)
State of lang units
E DC 10
S DC 10
NY E 5
PA S 5
Based on query, I need the values in table C as mentioned below.
Table C (Table of Destination) (necessary output query must also be as below)
The State value
PA 8
DC 1
My query is
INSERT INTO C(STATE,VALUE)
SELECT A.STATE, SUM ($) /SUM (UNITS)
OF A, B
WHERE PAYMENT = "SINGLE".
AND A.STATE = B.STATE
GROUP OF A.STATE, B.STATE
But the output I get is
PA 8
DC 2
Essentially to DC, I should get 1, i.e., for payment only $ DC is 20 and divided by 20 DC must be 1.
Let me know where I'm missing.Hello
It will work you need to add units in the group by clause
SELECT a.state, SUM (dollars) / units FROM a, (SELECT state, SUM (units) units FROM b GROUP BY state) sub WHERE payment = 'SINGLE' AND a.state = sub.state GROUP BY a.state, units;
Concerning
-
How to read/select only the records from a table with non-English characters
Hello
I need to find all records in a table with non-English (mainly Chinese) characters in at least one of the varchar2 columns. Let me kow if someone knows a way by which it can be done using SQL/PLSQL.
Best regards
Imranselect * from your table where your_column != convert(your_column, 'UTF8', 'US7ASCII)
Replace UTF8 with your database character set
Published by: thtsang on October 15, 2009 03:53 - unequal sign change of! =
-
Kindly help me with the request to find the data in two tables
Hello Guru
Kindly help me to recover the data from two tables-
BASEBALL
LEGAL_ENT_ID (PK)
GAME_ID (FK)
LEGAL_ENT_NM
INACTIVE_DT
DATE OF INS_TS
INS_LOGIN
DATE OF UPD_TS
UPD_LOGIN
FOOTBALL
GAME_ID (PK)
BRKR_NM,
BRKR_ISR_ID
BROKER_SYMBOL
INACTIVE_DT
BRKR_SWIFT_FLG
BRKR_INTERNAL_FLG
BRKR_CATEGORY
UPD_TS
MINORITY_FLG
BROKER_TYP
STATUS
INS_TS
INS_LOGIN
UPD_LOGIN
APP_USER
ACTIVE_FLG
and if I want fecth data from these two tables according to the following condition then it is fine with the suite of applications.
1 select distinct values only table of BASEBALL by using the following query.
SELECT DISTINCT B.GAME_ID as 'CLEARING GAME ID', B.BRKR_NM "NAME of THE GAME of COMPENSATION" OF BASEBALL A, FOOTBALL B WHERE A.BROKER_RELATION_CD IN ('FUTBRKR1', 'FUTBRKR2') AND A.GAME_ID = B.GAME_ID
2 Select all the table BRKR_NM OF FOOTBALL as well by using the query - next
SELECT GAME_ID "RUNNING GAME ID", 'NAME OF THE GAME OF EXECUTION' BRKR_NM SOCCER
Now, my query is that--
I want a query that gives me a combination of above mentioned queries... and if I tried to use Union or Union All, then she is not giving me the result as expected.
I like the result to look like who has a few conditions such as -
1 - the records in the table Football are high vs Baseball table because there is no condition to filter the records of the Football.
2 - football is a superset of records and Baseball is a subset.
3 - COMPENSATION NOM_JEU and RUNNING NOM_JEU may return the same values as well.
I want the result to be in the following form-
EXECUTION ID GAME | NAME OF THE GAME TO RUN. COMPENSATION ID GAME | DELETE THE NAME OF THE GAME.
2123 test1 2345 test5
2456 test10 2456 test10
Thanks in advance. Kindly help me.
Published by: user555994 on January 4, 2011 23:48In the output you want.
All the values of baseball;
Values of football that are matched;
But on what condition you want to match? -
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;
/
-
How this code deletes the record from the database company?
Hello, I'm at the beginner level and I would like to learn more about this code of a book. I have several questions below, I hope I can get any help
Thank you
· How this code deletes the record from the database company?
· Where is the connection to the db?
· What part or command is that deletes the record?
· What does that mean?
< link rel = "stylesheet" href = "styles.css" >
< html >
< head >
< /title > < title > test code
< link rel = "stylesheet" href = "styles.css" >
< / head >
< body >
< h1 > delete a record from the company < / h1 >
< table >
< action = "CompanyDeleteForm.cfm cfform" method = "POST" > "
< b >
< td > < table > C_ID
< td >
< cfinput type = "Text".
name = "C_ID".
message = 'Please enter the C_ID '.
validate = "integer".
required = "Yes".
size = "22".
MaxLength = "20" >
< table >
< /tr >
< b >
< td > < table >
< td >
< input type = "submit" value = "Delete a rec of the company" >
< table >
< /tr >
< / cfform >
< /table >
< / body >
< / html >
-----------------------------------------------
This isn't. He sends the value of C_ID in a form variable to an action (CompanyDeleteForm.cfm) page that would delete code.
Phil
-
Itried the benchmark tool, it did not help. I tried the scanning from the prompt, it says that some files were corrupted and could not repair them. There is no error message at all
Maybe the info will offer something that you haven't tried:
First, launch... Task Manager...
How to launch the Task Manager instantly in Windows XP or Vista?
http://www.XP-Vista.com/tipstricks/how-to-launch-the-Task-Manager-instantly-in-Windows-XP-or-VistaThe Task Manager / processes tab select (highlight) any which instance of:
"wmplayer.exe" and left click on the button "complete the process".If you see a dialog box 'Warning'... left click Yes.
Close the Task Manager.
Try Windows Media Player again.
And... the following links may be worth a visit:
(925704) when I try to use Windows Media Player 11, the program
does not start, or some user interface elements are empty
http://support.Microsoft.com/kb/925704Please see the following article for info on opening a high command
Prompt in VistaWindows Vista - command prompt: frequently asked questions
http://Windows.Microsoft.com/en-us/Windows-Vista/command-prompt-frequently-asked-questions
(scroll down to: how to run a command with elevated privileges?)Good luck...
-
Delete query to delete records from multiple tables
All,
I need a delete query that will delete the records from the tables. Please see the structure of the table & below
Now, I need to delete the records in these tables where the ID is '2000' by using a single delete query. Is this possible? This may be a newbie question. Help, please.CREATE TABLE TEMP1 (ID NUMBER(10),NAME VARCHAR2(40),CLASS VARCHAR2(40),COLLEGE VARCHAR2(40)); CREATE TABLE TEMP2 (ID NUMBER(10),CITY VARCHAR2(40),STATE(40)); INSERT INTO TEMP1 (ID, NAME,CLASS,COLLEGE) VALUES (1000,'SAM','CS','UNIV_1'); INSERT INTO TEMP1 (ID, NAME,CLASS,COLLEGE) VALUES (2000,'RIO','CS','UNIV_1'); INSERT INTO TEMP1 (ID, NAME,CLASS,COLLEGE) VALUES (3000,'CHRIS','CS','UNIV_1'); INSERT INTO TEMP1 (ID, NAME,CLASS,COLLEGE) VALUES (4000,'ALEX','CS','UNIV_1'); INSERT INTO TEMP2 (ID, CITY,STATE) VALUES (1000,'Auburn','NY'); INSERT INTO TEMP2 (ID, CITY,STATE) VALUES (2000,'Ithaca','NY'); INSERT INTO TEMP2 (ID, CITY,STATE) VALUES (3000,'Mount Vernon','NY'); INSERT INTO TEMP2 (ID, CITY,STATE) VALUES (4000,'Port Jervis','NY');
"using a single request deletion. Is this possible?
Nope.
You can insert into multiple tables by using a single query, INSERT ALL job, but you cannot delete more than one table using a single query. -
Correspondence of the columns from one table to another
I have a database column that contains the name of a person. I have another table that has a column that contains the names separated by a comma.
I want to match records where all records of two columns have a corresponding name. I tried this:
< cfquery name = "MyQuery" datasource = "myds" >
SELECT *.
OF TBL_A
WHERE TBL_A.customername IN (#DifferentQuery.ListOfNames #)
< / cfquery >
Everything that I try results in only get a recording. Basically, I want to get all records from a table where one of its columns contains the name of a column in another table.
It's a many-to-many relationship. That is to say an editorial can be linked to many ads, and vice versa. He is best represented with three tables. Such as:
Table: [Editorial] column: [EditorialID (PK), EditorialText,...]
Table: Columns of the [advertiser]: [AdvertiserID (PK), AdvertiserName]
Table: [Editorial_Advertisers] columns: [EditorialID, AdvertiserID]
The name of the advertiser throw himself into a column...
my client can decide which ads get related to which editorials
The third table stores the relationship between ads and editorials. So instead of storing a list of advertisers, you need to insert record for each EditorialID + AdvertiserID combination. You can then use joins to retrieve all the advertisements for EditorialID 123.
SELECT a.AdvertiserName FROM Editorial_Advertiser ea INNER JOIN Advertiser a ON ea.AdvertiserID = a.AdvertiserID WHERE ea.EditorialID = 123
-
Addign a computed column of the record count in table external
Hello
I have a csv file that is loaded using the external table. My need is to give a number to each record in the file and save it in one of the extra column in the table, can anyone suggest how it is possible?
The structure of the file is:
Now, my need is to give a number to each record... like the record from 7369, SMITH should be granted record n ° 1, 7499, ALLEN should be record No. 2 etc... can anyone suggest how it is possible?$cat emp.txt 7369,SMITH,CLERK,7902,12/17/1980,800,,20 7499,ALLEN,SALESMAN,7698,2/20/1981,1600,300,30 7521,WARD,SALESMAN,7698,2/22/1981,1250,500,30 7566,JONES,MANAGER,7839,4/2/1981,2975,,20 7654,MARTIN,SALESMAN,7698,9/28/1981,1250,1400,30 7698,BLAKE,MANAGER,7839,5/1/1981,2850,,30 7782,CLARK,MANAGER,7839,6/9/1981,2450,,10 7788,SCOTT,ANALYST,7566,12/9/1982,3000,,20 7839,KING,PRESIDENT,,11/17/1981,5000,,10 7844,TURNER,SALESMAN,7698,9/8/1981,1500,0,30 7876,ADAMS,CLERK,7788,1/12/1983,1100,,20 7900,JAMES,CLERK,7698,12/3/1981,950,,30 7902,FORD,ANALYST,7566,12/3/1981,3000,,20 7934,MILLER,CLERK,7782,1/23/1982,1300,,10 --and the table structure is: CREATE TABLE TMP_emp_ext ( EMPNO NUMBER(4), ENAME VARCHAR2(10), JOB VARCHAR2(9), MGR NUMBER(4), HIREDATE DATE, SAL NUMBER(7,2), COMM NUMBER(7,2), DEPTNO NUMBER(2) ) ORGANIZATION EXTERNAL ( TYPE ORACLE_LOADER DEFAULT DIRECTORY DIR_N1 ACCESS PARAMETERS ( records delimited by newline fields terminated by ',' missing field values are null ) LOCATION (DIR_N1:'emp.txt') ) REJECT LIMIT UNLIMITED NOPARALLEL NOMONITORING /
Thank you
orausernT. Kyte write RECNUM should work in http://asktom.oracle.com/pls/apex/f?p=100:11:0:P11_QUESTION_ID:52733181746448 #52977916329285 because it is SQL * Loader syntax. However I've wasn't able to make it work with Oracle 10.2.0.4. But in case of errors of loading, you should find in
_XXXXX.log the number of rejected records line (in my example it's the meaning of the 'line 2' "line 2"): erreur lors du traitement de la colonne EMPNO, la ligne 2, pour le fichier de données /tmp/emp.txt ORA-01722: invalid number
-
Delete records from a table of forms
Oracle forms6i
Hai All
I use forms6i and my need is I have generated a forms and the output is displayed through tables and I need to delete all the records from the table of my forms when executing next time pls tell me
Concerning
Srikkanth.MHello
Please try something like that.
Begin Delete From Master_Tbl Cascade; forms_ddl('Commit'); End;
Sarah
-
Extraction of data from two tables without discounting
Hi friends,
I have a problem I want to extract data from two tables without discount in the text field when I will enter any value in a text field, then the value of corressponding must come to textfield corressponding.
for example. There are two table A and B.
Table A has Colunm
S_ID number;
C_ID Varchar2 (30);
VARCHAR2 (4) s;
Second table B Colunm name
S_ID number;
What varchar (30);
L_Name varchar (20);
When I enter in a text field then the c_id 101 s_id, dry, first_name and last_name should come to corressponding text without refresh fields.
How can I do that.
Thank you
MauryYou can use Ajax and there are tons of good examples out there for this purpose;
For example [http://apex.oracle.com/pls/otn/f?p=31517:236:1876567353842241] -
How it warns Oracle to use an index for the join of two tables...
How to prevent the Oracle to use an index for the join of two tables to get a view online that is used in an update statement?
O.K. I think I should explain what I mean:
When you join two tables that have many entries sometimes there're better is not to use an index on the column that is used as a criterion to join.
I have two tables: table A and table B.
Table A has 4,000,000 entries and table B has 700,000 entries.
I have a join of two tables with a numeric column as join criteria.
There is an index on this column in A table.
So I instead of
I want to usewhere (A.col = B.col)
in order to avoid Oracle using the index.where (A.col+0 = B.col)
When I use the join in a select query, it works.
But when I use the join as inline in an update statement I get the error ORA-01779.
When I remove the '+ 0' the update statement works. (The column is unique in table B).
Any ideas why this happens?
Thank you very much in advance for any help.
Hartmut cordiallyYou plan to use a NO_INDEX hint as shown here: http://www.psoug.org/reference/hints.html
Maybe you are looking for
-
If I pre-order the Apple Watch in the 16th I will get for sure
I would like to pre-order the Apple Watch but im afraid that since I work until later that they will run out before I get to the store, if I pre-order I will get it the 16th or is - it possible that will run out?
-
5th generation refurb... what ios?
What ios is the 5th generation ipod touch?
-
ActiveX - Reg - led event reminder
Hello I'm building a control for a Laser machine which based its controls in the ActiveX control technology. I had a program in c# that works, but I have because I wanted to change the settings and then connect it to another program Labview, I "trans
-
Removes the stationary state backed up information during install it updates
We are a small school and only use stationary State for a few months. I found that some of the information that has been recorded on computers are being deleted when steady state allows updates each week. For example:Good research has been defined a
-
HP Wireless of D110 find two networks
My HP D110 found two networks with the same name... apparently one of my router Verizon Actiontech (several 192.X on channel 11) and one of my Apple Airport Express (10.0 several on Channel 6). The Network Setup page confirms this. After that the pow