Writing select from multiple tables, listed in another table
Hi there.
I need to write a select which is a little complex for me. Here is conditions,
All tables have the same column names, but i want to use staff_no.
All table names written in MASTER_TB table (15 table name).
is there a shortcut to write a sql like i am joining them?
(NO select * from staff t1, emp t2 ,company t3 .....etc....)
THANKS
you will have to write each tables just the same as writing a simple query. this is the part where you will have to write each tables in your FROM clause and any other column in the SELECT statement plus those condition expressions in your WHERE clause as to what you might be needing to arrive in the results that you needed.
Similar Messages
-
Copy selected values from a table control into another table control
hi there,
as seen in the subject i need to copy selected values from a table control into another table control in the same screen. as i dont know much about table controls i made 2 table controls with the wizard and started to change the code... right now im totally messed up. nothing works anymore and i don't know where to start over.
i looked up the forums and google, but there is nothing to help me with this problem (or i suck in searching the internet for solutions)
i have 2 buttons. one to push the selected data from the top table control into the bottom tc and the other button is to push selected data from the bottom tc into the top tc. does somebody has a sample code to do this?you're funny
i still don't get it... can't believe, there is no tutorial or sample code around how to copy multiple selected rows from a tc.
here's my code, maybe you can tell me exactly were i have to change it:
tc1 = upper table control
tc2 = lower table control
SCREEN 0100:
PROCESS BEFORE OUTPUT.
MODULE status_0100.
MODULE get_nfo. --> gets data from the dictionary table
MODULE tc1_change_tc_attr.
LOOP AT it_roles_tc1
INTO wa_roles_tc1
WITH CONTROL tc1
CURSOR tc1-current_line.
ENDLOOP.
MODULE tc2_change_tc_attr.
LOOP AT it_roles_tc2
INTO wa_roles_tc2l
WITH CONTROL tc2
CURSOR tc2-current_line.
ENDLOOP.
PROCESS AFTER INPUT.
LOOP AT it_roles_tc1.
CHAIN.
FIELD wa_roles_tc1-agr_name.
FIELD wa_roles_tc1-text.
ENDCHAIN.
FIELD wa_roles_tc1-mark
MODULE tc1_mark ON REQUEST.
ENDLOOP.
LOOP AT it_roles_tc2.
CHAIN.
FIELD wa_roles_tc2-agr_name.
FIELD wa_roles_tc2-text.
ENDCHAIN.
FIELD wa_roles_tc2-mark
MODULE tc2_mark ON REQUEST.
ENDLOOP.
MODULE ok_code.
MODULE user_command_0100.
INCLUDE PAI:
MODULE tc1_mark INPUT.
IF tc1-line_sel_mode = 2
AND wa_roles_tc1-mark = 'X'.
LOOP AT it_roles_tc1 INTO g_tc1_wa2
WHERE mark = 'X'. -
> big problem here is, that no entry has an 'X' there
g_tc1_wa2-mark = ''.
MODIFY it_roles_tc1
FROM g_tc1_wa2
TRANSPORTING mark.
ENDLOOP.
ENDIF.
MODIFY it_roles_tc1
FROM wa_roles_tc1
INDEX tc1-current_line
TRANSPORTING mark.
ENDMODULE. "TC1_MARK INPUT
MODULE tc2_mark INPUT.
IF tc2-line_sel_mode = 2
AND wa_roles_tc2-mark = 'X'.
LOOP AT it_roles_tc2 INTO g_tc2_wa2
WHERE mark = 'X'. -
> same here, it doesn't gets any data
g_tc2_wa2-mark = ''.
MODIFY it_roles_tc2
FROM g_tc2_wa2
TRANSPORTING mark.
ENDLOOP.
ENDIF.
MODIFY it_roles_tc2
FROM wa_roles_tc2
INDEX tc2-current_line
TRANSPORTING mark.
ENDMODULE.
thx for anybody who can help with this! -
Selecting from multiple tables, into one internal table
Hi,
What is the best & most efficient method of selecting from multiple table (in my case 6,) into one internal table?
Thanks,
John
Points will be rewarded and all responses will be highly appreciated.I have simple example :
First one - Join 5 tables
data : f1 type i,
f2 type i,
f3 type i.
start-of-selection.
get run time field f1.
write the query 4 or 5 tables join.
get run time field f2.
f3 = f2 - f1 ( Total time).
Second one - joins 3 table and use for all entries
data : f1 type i,
f2 type i,
f3 type i.
start-of-selection.
get run time field f1.
write the query 3 tables join and use for all entries
get run time field f2.
f3 = f2 - f1. ( Total time )
Finally you can have time diffrence between the both sql statement. -
Hi,
I am doing select from multiple tabels (2) in one SQL query.
How to get the result as it says.. Column name is incorrect ?
thanks,
-rajtreat the resultset as noraml. You get it in sequence as you have specified the column names. You use rs.getXXX(index) instead of columnname
-
How do I select from multiple schema's
How do I select from multiple schema's
Tried:
SELECT * FROM schema1.table1, schema2.table2
WHERE schema1.table1.column1 = schema2.table2.column2;
Errored......Thanks
We finally got in touch with our DBA and he said the same thing.
SELECT t1.*,
t2.*
FROM schema1.table1 t1,
schema2.table2 t2
WHERE t1.column1 = t2.column2;
I'll try it afther I finish a task my boss just gave me.
BRB then. -
How to select from multiple addresses of account in IC Web Client
Hi all,
We are implementing a B2C scenario for IC Web Client. We have customers with multiple addresses. However, when we search the acount, only standard address comes to screen. We want to be able select the related address, and then confirm the acount with that address.
Is there any way to customize the Web Client in order to be able to select from multiple addresses of the acount?
Thanks in advance.
Edited by: Danisman Danisman on Aug 31, 2010 2:52 PMThanks for the answer. Yes, we are using 7.0 but in the account identification screen, there is no personalize button ( I assume you are suggesting adding an addres block by using that button, right?).
We checked the necessary customizing : there is an entry for fucntional profile PERSONALIZATION : ALL_ENABLED.
Should we do something else to show the button?
Thanks again. -
Populate 1 table based on another table
I have a "VISITOR_TRACKER" application with the following 2 tables:
VISITORS (table)
VISITOR_ID (pk)
F_NAME
L_NAME
VISITOR_DETAILS (table)
V_DETAILS_ID (pk)
V_TIME_IN
V_DESTINATION
I want to do the following:
1. The visitor types in his/her last name in a search box.
2. Everyone with that last name shows up in either a report or a drop-down select list. The visitor selects his/her name.
3. A form "displays only" the name selected and has 2 text fields for the customer to enter their DESTINATION and TIME_IN and presses the submit button.
How do I set this up? The problem I'm encountering is that if I create a form w/report off of the VISITORS table, I'm unable to populate the DESTINATION and TIME-IN because the F_NAME and L_NAME from the VISITORS table is already popluted - it is trying to populate twice.
I tried basing the form w/report off of the VISITOR_DETAILS table but my report shows only the names that have any records in VISITOR_DETAILS. Also, the form shows the details of the VISITOR_DETAILS record that was selected.
My report query looks like this:
select "VISITOR_DETAILS"."V_DETAILS_ID" as "V_DETAILS_ID",
"VISITOR_DETAILS"."VISITOR_ID_LU" as "VISITOR_ID_LU",
"VISITORS"."F_NAME" || ' ' || "VISITORS"."L_NAME" as "NAME"
from "VISITOR_DETAILS" "VISITOR_DETAILS",
"VISITORS" "VISITORS"
where "VISITOR_ID_LU" = "VISITOR_ID"
I prefer to have a drop-down select list instead of a report if possible.
Please help! I have been working HOURS on this?if you only want a duplicat of the structure and don't worry about constraints, indexes, triggers etc you could use something like this
create table emp_dup as
select * from emp
where 1=0;Another more flexible way is to use the package DBMS_METADATA
http://download-west.oracle.com/docs/cd/B10501_01/appdev.920/a96612/d_metada.htm#ARPLS026 -
How to update one table based on another table ??
Hello Friends:
I am trying to run the following query in oracle but it won't run.
UPDATE BOYS
SET
BOYS.AGE = GIRLS.AGE
FROM GIRLS
WHERE
BOYS.FIRSTNAME = GIRLS.FIRSTNAME AND
BOYS.LASTNAME = GIRLS.LASTNAME;
This query runs fine in sql server but in oracle its saying can't find "SET". PLease tell me what is the correct syntax in oracle to update one table based on another table.
thanksSee if this helps.
If you wrote an SQL statement:
update boys set age = 10;
Every row in the boys table will get updated with an age of 10. But if you wrote:
update boys set age = 10
where firstname = 'Joe';
Then only the rows where the firstname is Joe would be updated with an age of 10.
Now replace the 10 in the above statements with (select g.age from girls g where g.firstname = b.firstname and g.lastname = b.lastname) and replace where firstname = 'Joe' in the second statement with where exists (select null from girls g where g.firstname = b.firstname and g.lastname = b.lastname). The same concepts apply whether 10 is an actual value or a query and whether you have a where clause with the update statement to limit rows being updated.
About the select null question regarding the outer where clause:
Since the query is checking to see if the row in the girls table exists in the boys table what the column is in this select statement doesn't matter, this column isn't being used anywhere. In this case Todd chose to use null. He could have also used a column name from the table or a lot of times you'll see the literal value 1 used here. -
Best way to create a table based on another table
Hello,
I am trying to create a table based on another table with all the data in it. It has large data.
create table <tablename> as select * from table1.
Is this the best way of doing it or is there any other way. please advice.
thanksI am suggested to create new table as
create table <newtable> as
select * from <oldtable> where rownum < 1;
then
alter table <newtable> compress;
then
insert /*+ append */ into <newtable> as select * from <oldtable>;
but i getting an error saying missing values key words ora- 00926.
please advice -
How to insert One table value to Another Table
Hi friends
Please have a look on this Code. Since i am new Java i am not able to findout the Solution for it
private void displayavailablity(String selecteditem1)
try
Vector columnNames = new Vector();
Vector data1 = new Vector();
String bname,bauthor,bcategory,bref1,bavail,bid;
int bref,mid,num;
rs = st.executeQuery("SELECT * FROM Books where BAuthorandPublisher='" + selecteditem1 +"'");
while(rs.next())
bname = rs.getString("BName");
bauthor = rs.getString("BAuthorandPublisher");
bcategory = rs.getString("BCat");
bref = rs.getInt("BRef");
if(bref==1)bref1="Yes";
else bref1 = "No";
mid = rs.getInt("Mid");
if(mid==0)bavail="Available";
else bavail="Issued To:"+mid;
bid = rs.getString("BId");
System.out.println("Book Name is::"+bname);
System.out.println("Book Availabilty::"+bavail);
num = st.executeUpdate("insert into BSearch Values('"+bid+"','"+bname+"','"+bcategory+"','"+bauthor+"','"+bavail+"','"+bref1+",')");
System.out.println("Inseted in the table");
/**ResultSetMetaData md= rs.getMetaData();
int columns =md.getColumnCount();
String booktblheading[]={"Book ID","Book NAME","BOOK AUTHOR/PUBLISHER","REFRENCE","CATEGORY"};
for(int i=1; i<= booktblheading.length;i++)
columnNames.addElement(booktblheading[i-1]);
while(rs.next())
Vector row = new Vector(columns);
for(int i=1;i<=columns;i++)
row.addElement(rs.getObject(i));
data1.addElement(row);
//System.out.println("data is:"+data);
((DefaultTableModel)table.getModel()).setDataVector(data1,columnNames);
//DefaultTableModel model = new DefaultTableModel(data1,columnNames);
//table.setModel(model);
rs.close();
//st.close(); */
catch(SQLException ex)
}I trigger this Method when a JComboBox Item is Selected.
For an example when i select an Item the select Query brings all the Record Equals to the Selected item. Now i want to insert the Selected items with some Modification to Another Table.
Now the Problem is My Program Inserts Only One Record (Though there are Many Records Equals to Selected Item)
Please give me a Better Solution
Thank youjolif,
If you're "new to java" then might I suggest you leave swing until you're "not so new to java"... it involves so many "advanced concepts" (unlike VB) that it constitutes a biohazard... i.e. it's fundamentally inimical to humanoid lifeforms.
Now... Having duly vented my spleen, try rs.updateRow(); -
A table cannot overlap another table
Hi all,
I have a pivot table pulling data from a range. When I try to insert table into the rage, I get the error message "A table cannot overlap another table"? I had initially inserted a table into the range and everything worked fine, but recently the
TABLE TOOLS/DESIGN option in the ribbon bar don't show anymore!! so I figured to insert a table and that's when i got the above error message.
When I try to refresh my pivot table I get this error message "We couldn't load the Data Model. This may be because the Data Model in this workbook is damaged".
What's happening?Hi,
Glad to hear you have solved it and thanks for sharing the experience here, it will definitely be hepful to others who meet the same problem.
Regards,
Melon Chen
TechNet Community Support -
Import Table Statistics to another table
Hi,
Just like to know if I can use dbms_stats.import_table_stats to import table statistics to another table?
Scenario:
I exported the table statistics of the table (T1) using the command below.
exec dbms_stats.export_table_stats('<user>','T1',NULL,'<stat table>');
PL/SQL procedure successfully completed.
And then, I have another table named T2, T1 and T2 are identical tables. T2 does not have statistics (I intentionally did not run gather statistics). I am wondering
if I can import table statistics from T1 to T2 using dbms_stats package?.
For what I understand, statistics can be imported back at the same table which is T1 but not for another table using dbms_stat package. If I am wrong, anyone can correct me.
Thankshi
just try ;-) you lose nothing probably,
check afterwards last_analyzed value for that table in user_tables
if something is wrong, run regular stats -
Physical table list against Cluster Table CDPOS and PCDPOS
Hello experts,
For function customized requirement, we need to know the physical table
list against Cluster Table CDPOS and PCDPOS and EDID4, just like
Cluster Table BSEG contain with six physical tables
BSAD/BSID/BSAS/BSIS/BSAK/BSIK. Also we want to know if there is any
general way to find out the physical table list for any cluster table.
My question is:
1. How can I find all the transparent table for Cluster Table CDPOS?
just like Cluster Table BSEG has transparent tables of
BSAD/BSID/BSAS/BSIS/BSAK/BSIK.
2. How can I find all the transparent table for Cluster Table PCDPOS?
3. How can I find all the transparent table for Cluster Table EDID4?
4. Additionally,I want to know if there is any
general way to find out all the transparent tables for an specific
cluster table.
Many thanks.Hello,
simply look in transaction SE11.
Example:
1. SE11 -> Table CDPOS - Display. On Tab 'Delivery and Maintenance' you'll find Pool/Cluster 'CDCLS'.
2. SE11 -> Table CDCLS -> Display. On next screen position on CDCLS-> Where-used-list -> Tables -> you'll find tables CDPOS and PCDPOS.
Same thing with EDID4 -> EDI40 ...
Regards Wolfgang -
How to select from multiple output tables in the SAP Data Source
Hi,
We're using the SAP Data Source to display SAP data in our portal from the Bapi: BAPI_INFORECORD_GETLIST. When defining the Bapi Meta Data we can select data from one of the two output tables (INFORECORD_GENERAL and INFORECORD_PURCHORG). But we want to select data from both tables (some columns we want to show are in INFORECORD_GENERAL and some are in INFORECORD_PURCHORG) .
How can we do this ?
With regards,
Ramon van der WeidenYou can query multiple TimesTen databases, but your original question was about joining tables from two databases, which is not supported.
Using Cache Connect to Oracle to query an Oracle database is not distributed. It's still one single Oracle database you are querying. You cannot join a table in the TimesTen database with a table in the Oracle database, this is not allowed.
If you are willing to share your business requiremens, we can take a look and see what solution might work for you. Would you like to discuss this offline?
Susan -
Sample PHP Service selecting from multiple tables
Hi all!
I have the following challange:
How do I properly set up my PHP-service to insert, select, update and delete values from multiple tables?
So far, the standard templates generated by Flash Builder is based on a single table.
Example: I have 2 tables: [person] and [school]
[person] has [person_id, first_name, last_name, birthdate]
[school] has [school_id, person_id, school_name, city]
One [person] can have multiple [schools]
How should I define the selectByID function in PHP to be able to have
First name: [TextInput /]
Last name: [TextInput /]
Birthdate: [DateField /]
Schools:
[TabBar: School1, School2, School3 /]
[ViewStack1]
School name: [TextInput /]
Location name: [TextInput /]
[/ViewStack1]]
[ViewStack2]
School name: [TextInput /]
Location name: [TextInput /]
[/ViewStack2]]
[ViewStack3]
School name: [TextInput /]
Location name: [TextInput /]
[/ViewStack3]]
And even more interesting: How do I update all these fields back to the database?First, the relationship between school and person is many-to-many NOT one-to-many -- you will need to add a junction table.
From the form you have given I would handle insertions like this:
loop through all the schools and see if the school already exist in the DB. If so, then store the school_id. If not, then create a new record and store the id. You should have an array collection of store_ids by the end of the loop
Check whether the student exists w/in the DB. If so, then you might consider aborting the operation or you could opt to do an update. If the student doesn't exist, then create a new student record and store the new student_id (mysql::insert_id)
Loop through the school_id array and add new student_id/school_id records into the junction table.
Retrieving records is much simpler -- it's just a join on the tables i.e. "SELECT * FROM student INNER JOIN school_student ON student.student_id = school_student.student_id INNER JOIN schools ON school_student.school_id = school.school_id WHERE student.first_name = 'John' AND student.last_name = 'Doe' (assuming there aren't more than one John Does of course!).
- e
Maybe you are looking for
-
CS4 Master Collection Application Verion Info ???
Can someone please provide me the Version #'s to each of the applications in CS4? The only info I can find online is written like this "Adobe Photoshop CS4" and so on for each application, however, Photoshop CS4 is version 11.0 if I'm not mistaken.
-
Purchase Order Module - Goods Receipt PO - Goods Return - AP Invoice
Hi all expert, I have a senario is :- Open Purchase Order Module -> Goods Receipt PO -> Goods Return -> AP Invoice Puchase Product A by "Purchase Order" with Qty 6,000 After "Good Receipt PO", found out 3,500 pcs is out of spec then "Goods Returns"
-
Hi, I've ripped a movie DVD I own and burned it to a Sony DVD-R . It plays fine on a DVD player connected to a TV set, but not in DVD Player on my MacBook Pro with Leopard. Keeps telling me that it's not recognized or something. What can be wrong? Th
-
Greetings All, Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production Windows 2008 R2I had 18 unexplained columns appear on a table in one of the schemas. The column names are like SYS_000080$, SYS_000079$, ... Anybody know if g
-
Need help with scripting Jumps
Hi - hope someone can help me. I'm in over my head. I have a long (4 hrs.) commercial video track separated by dozens of markers (placed earlier in FCP). All my menu buttons work fine, but I want to include a button which serves as an "In-Store" demo