Retriving single field from two tables which are unrelated
Hi experts..
i would like to retrieve a field say X from two database tables TAB1 and TAB2 which are unrelated . Can you give me a way to retrive the field X from TAB1 and TAB2 in a single select statement on perticular condition.
Reward points if aswered..
Hi,
If the field is in two tables,you can use for all entries. But anyway two select statemetns are needed.
If you want single select statement, try using subquery.
Similar Messages
-
I need to add a single field from with_item table . need to write select query with reference to company code , account doc no , fiscal year
Hi Arun ,
Can you explain little bit more ??
what is account doc no?
what are the transactions should be displayed in your output??
-Rajesh N -
Generate delta records by comparing multiple fields from two tables?
I have two tables with similar fields. Let's say Table 1 (T1) has fields Customer, A, B and C. Table 2 (T2) has fields Customer0002, A0002, B0002 and C0002. For each customer (each record) I want to check whether there is any difference in field A and A0002 or B and B0002 or C and C0002. If there is a difference between any of these pairs of fields then I will update that customer's record. Currently I have a piece of code
DATA: ls_source TYPE y_source_fields,
ls_target TYPE y_target_fields.
LOOP AT it_source INTO ls_source.
if not ( ls_source-A = ls_source-A0002 ).
MOVE-CORRESPONDING ls_source TO ls_target.
APPEND ls_target TO et_target.
endif.
ENDLOOP.
This checks for the difference between one pair - A and A0002. How can I make it check 3 pairs and update when any of them have differences?Hello Khaled
Why don't you add B and B0002 - C and C0002 fields into your if declaration?
LOOP AT it_source INTO ls_source.
if not (
ls_source-A = ls_source-A0002 and
ls_source-B = ls_source-B0002 and
ls_source-C = ls_source-C0002
MOVE-CORRESPONDING ls_source TO ls_target.
APPEND ls_target TO et_target.
endif.
ENDLOOP.
I think you have more than 3 fields and the count of these fields are dynamic right?
Do you about the ASSIGN COMPONENT x OF STRUCTURE y TO <field_symbol>. usage?
Can you explain your need in detail please.
Edited by: Bulent Balci on Jul 27, 2010 4:18 PM -
Write fields from two tables in one line??
Hi friends,
I want to write some fields from bkpf and bseg in one line...
My report should like something like this:
****some text*****
*for first document******* bkpf-bldat kunnr bseg-belnr bseg-gsber bseg-wrbtr
*for second document*** bkpf-bldat kunnr bseg-belnr bseg-gsber bseg-wrbtr
*for third document****** bkpf-bldat kunnr bseg-belnr bseg-gsber bseg-wrbtr
etc.
What should I change in order to get this form in report output?? Can I put these fields in some table so that it looks like excel table??Could you please check out the code below?
loop at it_bkpf into wa_bkpf.
loop at it_bseg into wa_bseg.
write: wa_bseg-gsber, wa_bseg-belnr, wa_bseg-wrbtr.
endloop.
write: wa_bkpf-bldat.
read table it_bsid with key bukrs = wa_bkpf-bukrs
belnr = wa_bkpf-belnr
gjahr = wa_bkpf-gjahr
cpudt = wa_bkpf-cpudt.
if sy-subrc = 0.
write: it_bsid-kunnr.
endif.
endloop.
Thanks,
Nihadhi nihad,
define positions on where to write data like this.
LOOP AT it_bkpf INTO wa_bkpf.
LOOP AT it_bseg INTO wa_bseg WHERE belnr EQ wa_bkpf-belnr.
WRITE: /5 wa_bkpf-bldat.
READ TABLE it_bsid
WITH KEY bukrs = wa_bkpf-bukrs
belnr = wa_bkpf-belnr
gjahr = wa_bkpf-gjahr
cpudt = wa_bkpf-cpudt.
IF sy-subrc EQ 0.
WRITE: 20 it_bsid-kunnr.
ENDIF.
WRITE: 35 it_bseg-belnr,
50 it_bseg-gsber,
60 it_bseg-wrbtr.
ENDLOOP.
ENDLOOP.
regards,
Peter -
How to access records from two tables which have no relation
Hi,
I trying to generate a report where i need to print the company details at the top of the page and invoice details of that down the page.There is no relation between these two tables.I am not able to write two queries for one report.Pls some one assist me in getting this thing done.
Regards,
Tulacenath.Hi Tulacenath
So your invoice table does not have a reference to the customers (companys) that the invoices belong to?
Tim -
How to get the data from a table which are availble in MD04
Hello,
Can you please let me know the tables in which the 'data available in MD04' are stored.
I would like to have the data pertaining to the customer order/Item with requirements available in MD04.
Thanks and Regards,
Jana.Probably the easiest way in this case is to run the performance trace (System/Utilities/Performance trace). Start transaction MD04, put on the trace in another window, press enter to see the stock/requirements list, then stop the trace and list the results. Then you'll see which tables were accesses with which queries.
-
Query works fine when I query one table. When I add the
second it generates the following error.
-1:[Macromedia][SequeLink JDBC Driver][ODBC
Socket][Microsoft][ODBC Microsoft Access Driver] Could not find
file 'C:\CFusionMX7\db\slserver54\logging\mob.mdb'
See code.
Thank youAlso does Access understand this way of joining tables? I do
not
believe I have very seen Access SQL that did not use INNER
JOIN syntax.
I.E.
FROM mob_user JOIN mob_user_type ON mob_user.user_type_id =
mob_user_type.user_type_id -
Selecting from two tables and confirming from them despites they not relate
Please I need a query to select from two tables that are not related to each other.
I also want to confirm data's as in verify wether what the user has entered is in accordance with what is in the tables
Examples
the first table is named "Card" and the second table is named "Student_Details"
Card table contains a column named "Pin_Number".
The Student_Details table contains fields such as Exam_Number, Name, Age, Sex.
The user has to Enter the Pin_Number which has to be confirmed in the Card table and Exam_Number which has to be confirmed in the Student_Details table and verify that both data's are correct.
Please I need the SQL and PL/SQL queries for this problem.
ThanksHi,
I think you need two different queries
You can write a procedure like:
create or replace procedure p1 (p_pin_number number, p_exam_number)
is
r_card_row card%rowtype;
r_student_details student_details%rowtype;
cursor c1 is
select *
from card
where pin_number = p_pin_number;
cursor c2 is
select *
from student_details
where exam_number = p_exam_number;
begin
open c1;
loop
fetch c1 into r_card_row;
exit when c1%notfound;
.... do whatever you want..... and the samething you can do with other cursor
end loop;
close c1;
end p1;Hope this helps
Ghulam -
ALV OOps report- getting data from two tables and adding issue
Hi,
This is sales employee performance report.
I need to select all the fields from two tables based on user input ie VKorg, sales employee .
There is one field callled " Net sales"in both the tables.
Based on sales employee number, i need to add that net sales which i get from two tables.
I need to generate single report.
Can you give some inputs reg. the select query.
My idea is select all the data from both tables using join statement.
ThanksHi,
I have written like this:
select * from S002 as a join S006 as b
into table ME->SS002_RAW[]
where vkorg in me->select_parameters->SO_VKORG[] = vkorg in me->select_parameters->SO_VKORG[]
and ZZSLSEMP01 in me->select_parameters->SO_so_empl[] = ZZSLSEMP02 in me->select_parameters->SO_so_empl[].
when i do like that,
I am getting error
Incorrect structure of FROM clause . . . .
If you give some idea on this
Edited by: Raja on Apr 22, 2009 11:19 AM -
Selecting columns from two table is slow but same
I am selecting 27 columns from two tables
which running for more than 30 minutes. but
if I select count(*) with the same query
except the columns it is coming in seconds.
Where is the error?If you post
1) The table definitions for the underlying tables
2) The indexes that are on the tables
3) The two SQL statements you're running
4) The explain plan for both statements
we can probably be of some assistance.
My guess is that the count(*) is able to return much more quickly because the optimizer is able to use a significantly faster query plan that is based on an index which the longer-running query cannot utilize. Without the information I've requested, though, it's hard to do more than speculate.
Justin
Distributed Database Consulting, Inc.
http://www.ddbcinc.com/askDDBC -
Join two tables which stored in difference database
Hi, i have a problem how to join two tables which are stored in difference databases. I'm using MS access and need to use Jsp to solve it. is anyone have idea to solve it. thxx
Hi,
I think you cannot join the tables which are in two diff databases. You have to connect to each database ,get the result and manipulate in your program. Use a bean.
cheers,
Narayana -
Retrive data from two tables into one internal table.
Hi SDN,
I am downloading the Assets data from two tables ANLA,ANLZ.
there is a common field ANL1in both tables and i have to retrive the data by using anl1 into the internal table.
can you please send me the SELECT Syntax for this probl.....
Thank you & Regards,
ManojHi manoj,
Please see the following sample code. But kindly don't use join as it may hamper ur performance. No trouble in using two select query.
data: begin of itab occurs 0,
BUKRS like anla-BUKRS,
ANLN1 like anla-ANLN1,
BDATU like anlz-BDATU,
end of itab.
select anlabukrs anlaANLN1 anlzBDATU into corresponding fields of table itab from anla inner join anlz on anlaanl1 eq anlz~anl1 where (logexp).
Please come back for any clarification.
Thanks and Regards,
saurabh -
Delete records from tableA which are not in tableB
Table A contains milions of records which is the best way to delete records from tableA which are not in tableB
delete from tableA where empno not in (select empno from tableb)
or
delete from tableA where empno not exists (select empno from tableb
where b.empno=a.empno)
any helpHi
If you can do this, do with this:
create table tableC
as select a.*
from tableA a,
(select empno from tableA
minus
select empno from tableB) b
where a.empno = b.empno;
drop table tableA;
rename table tableC to tableA;
Ott Karesz
http://www.trendo-kft.hu -
How do I remove songs from my iPad which are no longer present in my library. Normal synching works for everything else except two songs ' stuck' on my iPad ?? Any solutions. ???? Thanks.
You can remove them manually on the device. Swipe across the track to bring up a delete button.
tt2 -
Create a procedure which requires displaying information from two tables
What if we want to create a procedure which requires displaying information from two tables. In this situation,
I need to display all the details of an employee from an 'emp' table based on the deptno. and also their salary information which is
stored in "Salgrade" Table. Is the use of "And" the correct way of using it?
Do I need to declare all the attributes before begin or I can just access them directly? Thanks
Create Procedure findDept
( I_deptno IN number
) As
Begin
Select Ename, Job, MGR, Hiredate, Sal, Comm, Dept_no from emp and exp, grade , location from salgrade where dept_no
= I_Deptno;
Exception
When NO_Data_Found then
DBMS_Output.Put_Line(' Department not found"|| I_deptno);
End findDept;Hi,
Besides Qwerty's remark, you've also got a quoting error:
Change
DBMS_Output.Put_Line(' Department not found"|| I_deptno);
{code}
into
{code}
dbms_output.put_line(' Department not found: '|| i_deptno);
{code}
Which leads to the question:
What do you want to do when a record is found?
Display it?
Maybe you are looking for
-
Text rendering on MacBook Pro differs from PowerBook.
It appears that various applications use a different text rendering technique on the MacBook Pro than on the Powerbook. Camino for instance uses sub-pixel rendering on the PowerBook but standard anti-aliasing on the MacBook Pro. So do Word and MSN an
-
hi, i wont to increase performance for this loop what is the best way to do that? LOOP AT q_tab ASSIGNING <q_tab>. SELECT SINGLE txtmd FROM /bi0/tqualifictn INTO <q_tab>-txtmd WHERE qualifictn = <q_tab>-nodename AND langu
-
Logical host resource in SC3.2 missing IPMP
I was under the impression that when creating a logical host resource in Solaris Cluster 3.2, that it will read the hosts and hostname.* files to get the IPMP info and do this automatically for you. I am not seeing this behavior and am hoping someone
-
HTML generator script (in Ruby) - what do yout think about it?
Hi folks, since I have a lot of time recently, I decided to create a little (non-dynamic) website with HTML and CSS. So, when I began writing I noticed that there is a lot of "typing overhead" what really went on my nerves. Be it as this may... I was
-
Connecting AEBS to third party modem/router
I'm not having any luck setting up my AEBS as remote basestation to connect wirelessly to my Zyxel wireless modem/router. I have the AEBS wired to my quad G5. In Airport Admin Utility of the internet settings Airport WDS is selected. At the WDS host