Select query----- inner join codition
i have used below query to get fields from ekpo and eket tables.
i am getting error as the column name 'ebeln' has two meanings.
SELECT A~EBELN
A~EBELP
A~TXZ01
A~MENGE
A~MEINS
A~NETPR
A~NETWR
B~EINDT
FROM EKPO AS A INNER JOIN EKET AS B
ON AEBELN = BEBELN
AND AEBELP = BEBELP
INTO CORRESPONDING FIELDS OF TABLE IT_ITEM
WHERE EBELN = I_EBELN.
please tell what could be the problem
regards,
krishna
Hi Krsihna,
refer below code:
WHERE A~EBELN = I_EBELN. or WHERE b~EBELN = I_EBELN..
Thanks
Piyush
Reward Points, if helpfull
Similar Messages
-
Hi,
Please give me the Select query
I have to fetch EBELN,BUKRS,LIFNR,BSART,EKORG,EKGRP,WAERS,WKURS from EKKO and
EBELP,LGORT,MATKL ,WERKS,BEDNR,IDNLF,BPRME,NETPR from EKPO and
MENGE, SAKTO,AUFNR,ANLN1,GSBER,PS_PSP_PNR from EKKN and
LPEIN,EINDT,SLFDT, from EKET.
I have to fetch all the data into an single internal table(Mandatory) by a select query using Joins.
EKKO is having EBELN as primary key
EKPO is having EBELN,EBELP as primary key
EKKN is having EBELN,EBELP as primary key
EKET is having EBELN,EBELP as primary key
Can anybody Please give me the Select query.
With Regards
AjayHi ,
I am sending this sample coed for the Inner joins .Hope this will help you:
Inner joins using 3 tables
Try this :-
SELECT stpostlnr stpoidnrk mastmatnr maramtart stpo~menge
INTO CORRESPONDING FIELDS OF TABLE zmat1 FROM mast
JOIN stpo ON stpostlnr = maststlnr
JOIN mara ON maramatnr = mastmatnr
WHERE stpostlty = 'M' "AND stpoidnrk IN s_matnr
AND mast~werks = 1000.
Here s_matnr is a select-options on the selection-screen.
Or this.
Code:
Select single VbrkBukrs VbrkKunrg Vbrk~Vbeln
VbrkFkdat VbrkBstnk_Vf Vbrk~Zterm
Tvzbt~Vtext
VbakVbeln VbakBstdk
LikpVbeln Likplfdat Likp~Lfuhr
into w_vbrk
from vbrk
inner join Tvzbt on TvzbtZterm = VbrkZterm and
Tvzbt~Spras = sy-langu
Inner join Vbfa as SalesLnk
on SalesLnk~vbeln = pu_vbeln and
SalesLnk~vbtyp_v = c_order
inner join Vbak on VbakVbeln = SalesLnkVbelv
Inner join Vbfa as DeliveryLnk
on DeliveryLnk~vbeln = pu_vbeln and
DeliveryLnk~vbtyp_v = c_Delivery
inner join Likp on LikpVbeln = DeliveryLnkVbelv
where vbrk~vbeln = pu_Vbeln.
This code locates sales, delivery and payment terms info from a billing document number.
or
Here, this one also works fine :
select zfpcdcadivi zfpcdproforma zfpcdfactura zfpcdaniofactura
zfpcdmontousd zfpcdmontoap zfpcdebeln zfpcdinco1
zfpcdlifnr lfa1name1 zcdvsstatus zfpcdconint
into it_lista
from zfpcd inner join zcdvs
on zfpcdebeln = zcdvsebeln
and zfpcdproforma = zcdvsproforma
and zfpcdlifnr = zcdvslifnr
inner join lfa1
on zfpcdlifnr = lfa1lifnr
where zcdvs~status = '04'.
Also Here is another solution that just uses inner joins:
SELECT vbakvbeln vbfaerdat INTO (itab-vbeln, itab-wadat)
FROM ( vbak INNER JOIN vbap
ON vbapvbeln = vbakvbeln )
INNER JOIN vbfa ON vbakvbeln = vbfavbelv
WHERE vbak~kunnr = m_wm AND
vbak~vbtyp = 'C' AND
vbfa~erdat IN s_date AND
vbap~matnr = 'MZ1807F' AND
vbfaposnv = vbapposnr AND
vbfa~vbtyp_n = 'J'.
<REMOVED BY MODERATOR>
Cheers,
Chandra Sekhar.
Edited by: Alvaro Tejada Galindo on Apr 10, 2008 5:20 PM -
Problem with a query inner-join
Hello;
I'm trying to innerjoin these 2 tables in my query for a page that will allow you to add / edit records. Right now, it's telling me I have a data mismatch. I don't see where I went wrong. Can someone help me out?
This is my code:
<cfparam name="url.CategoryID" type="integer" default="0">
<cfparam name="subID" type="integer" default="#url.CategoryID#">
<cfparam name="subName" default="">
<cfparam name="CategoryID" default="">
<cfparam name="Name" default="">
<cfif url.CategoryID GT 0>
<cfquery name="categRec" dataSource="#APPLICATION.dataSource#">
SELECT merchSubCat.subName, merchSubCat.subID, Categories.CategoryID, Categories.Name
FROM merchSubCat
INNER JOIN Categories
ON merchSubCat.CategoryID = Categories.CategoryID
WHERE merchSubCat.subID = <cfqueryparam value="#url.CategoryID#" cfsqltype="cf_sql_integer">
</cfquery>
<!--- if the record was found, store the values --->
<cfif categRec.RecordCount EQ 1>
<cfset CategoryID = categRec.subID>
<cfset subName = categRec.subName>
<cfset CategoryID = categRec.CategoryID>
<cfset Name = categRec.Name>
</cfif>
</cfif>
this is my error:
Error Executing Database Query.
[Macromedia][SequeLink JDBC Driver][ODBC Socket][Microsoft][ODBC Microsoft Access Driver] Type mismatch in expression.
The error occurred in C:\Websites\187914kg3\admin\cms\merchant\merchSub-edit.cfm: line 16
14 : INNER JOIN Categories
15 : ON merchSubCat.CategoryID = Categories.CategoryID
16 : WHERE merchSubCat.subID = <cfqueryparam value="#url.CategoryID#" cfsqltype="cf_sql_integer">
17 : </cfquery>
18 :
I don't see what I did wrong, can another pair of eyes see where I missed something?
Thank youI changed it to number, and it works now.
I have one other problem.. I'm trying to use a drop down menu in this form to edit a record. I want the drop down to show what is being used in the database when you go to edit a record. It runs on one query, to populate the select, but it pulls info from another and this isn't working. Actually, it's the innerjoin I just made.. can you help me?
<!--- query that runs the select --->
<cfquery name="catList" datasource="#APPLICATION.dataSource#">
SELECT DISTINCT merchCategory.CategoryID, merchCategory.CatName AS cat_name
FROM merchCategory
ORDER BY CatName
</cfquery>
<cfselect enabled="No" name="CategoryID" size="1" class="smallText" multiple="no" query="catList" value="CategoryID" display="cat_name" queryPosition="below" selected="#categRec.Name#">
<option value="">--Select a Category--</option>
</cfselect>
As you see, in the selected part of the tag, I'm trying to pull info from the other query we just fixed. I know this is wrong, how do I do this? -
To Optimise SELECT- 9 INNER joins
iam using 9 database tables in my final itab and i want final-itab data to retrieved from 9 database tables satisfying the conditions of the user given data for 1st table later for 2nd 3rd 4th and upto 9 th database tables data to be retrieved from 1st to 2nd and for 3 rd it should be taken from 2nd..
so i have declared one finalitab and iam putting 9 inner joins .. so as data in my server is less so its getting but how to improve my SELECT query such that i can get faster unless the size of the data onthe server..
so please give me solution for the query...
Thanks in advance..please check .. this is my Select Query . and i dont want to have 9 itabs as iam working it for SMARTFORMS...
so i want all the data to be into one finalitab... so please give me.. good solution.. for the innerjoins.such that i can do it more.. ...
SELECT A~TKNUM
A~VBELN
A1~TDLNR
A1~TNDR_LTPD
A2~DISTZ
B~WERKS
C~VSTEL
D~BWKEY
D~BUKRS
E~BUTXT
F~KUNNR
G~NAMEV
G~NAME1
G~TELF1
H~ADRNR
I~ADDRNUMBER
I~NAME1
I~CITY1
INTO CORRESPONDING FIELDS OF TABLE IT_HEADER
FROM VTTP AS A INNER JOIN LIPS AS B ON AVBELN = BVBELN
INNER JOIN VTTK AS A1 ON A1TKNUM = ATKNUM
INNER JOIN VTTS AS A2 ON A2TKNUM = ATKNUM
INNER JOIN T001K AS D ON BWERKS = DBWKEY
INNER JOIN T001 AS E ON DBUKRS = EBUKRS
INNER JOIN T001W AS F ON DBWKEY = FWERKS
INNER JOIN KNVK AS G ON FKUNNR = GKUNNR
INNER JOIN LIKP AS C ON BVBELN = CVBELN
INNER JOIN TVST AS H ON CVSTEL = HVSTEL
INNER JOIN ADRC AS I ON HADRNR = IADDRNUMBER
WHERE A~TKNUM = P_SHIPNO.
where Tknum is the Shipment number.... taken from user as parameter.....
thnaks in advance.. -
Hi,
select sum( a~dmbtr )
into o_debit
from bsik as A inner join FAGLFLEXA as B
on abukrs = bRBUKRS
and agjahr = bRYEAR
and abelnr = bdocnr
where a~bukrs = x_bukrs
and a~lifnr = p_lifnr
and a~shkzg = 'S'
and a~budat in s_budat
and a~hkont gt '0000000000'
and a~hkont le '9999999999'
and b~prctr = p_prctr.
Above query is not giving result in o_debit though data is available in both the table. Please guide me, if I have written something wrong.Hi, Raj.
Test the following Sample It is working fine for me hope will work for you too, I did some little change.
TYPES: BEGIN OF ty_test,
dmbtr LIKE bsik-dmbtr,
END OF ty_test.
DATA: it_test TYPE STANDARD TABLE OF ty_test WITH HEADER LINE.
SELECT SUM( a~dmbtr ) as dmbtr
INTO CORRESPONDING FIELDS OF TABLE it_test
FROM bsik AS a INNER JOIN faglflexa AS b ON ( a~bukrs = b~rbukrs AND a~gjahr = b~ryear AND a~belnr = b~docnr )
WHERE a~bukrs = x_bukrs
AND a~lifnr = p_lifnr
AND a~shkzg = 'S'
AND a~budat IN s_budat
AND a~hkont GT '0000000000'
AND a~hkont LE '9999999999'
AND b~prctr = p_prctr.
Please Reply if still any Issue,
Best Regards,
Faisal -
Help with query - inner join and case
Hi this is the query I am having troble with, where is the correct place to add the case condition:
SELECT
FROM
END_USER_ORDERS EO
INNER JOIN ORDER_PRODUCTS OP
ON EO.EUO_ID = OP.EUO_ID
INNER JOIN PRODUCTS P
ON OP.PRD_ID = P.PRD_ID
CASE P.PRD_ID -- PROBLEM IS HERE
WHEN 'Online' Then 'Public'
END
INNER JOIN PRODUCT_VERSIONS PV
ON P.PRD_ID = PV.PRD_ID
AND PV.SIT_ID = 'DEFAULT'
AND PV.LOC_ID = 'UK'
LEFT OUTER JOIN ORDER_SESSIONS OS
ON OP.EUO_ID = OS.EUO_ID
AND OP.ORP_SEQ_NO = OS.ORP_SEQ_NO
LEFT OUTER JOIN SESSIONS S
ON OS.SES_ID = S.SES_ID
LEFT OUTER JOIN SUBJECTS SU
ON S.SUB_ID = SU.SUB_ID
WHERE EO.EUO_ID = 'bef8cd51-b398-4521-9350-f3a7c3885c59'
select * from END_USER_ORDERS
order by EUO_DATE desc
Many thankshmmm....one more point here, when you change your query use as below:
SELECT
Col1,Col2.... -- specify your columns
,CASE P.PRD_TYPE
WHEN 'Online' Then 'Public'
else P.PRD_TYPE -- to display others as original value
END AS [PRODUCT TYPE]
FROM
END_USER_ORDERS EO -
ORA-00947 Error on straight SELECT with INNER JOINs
I have a REAL bizarre situation. I have a SQL SELECT Statement that is joining a few tables. I actually have a WHERE clause where I am filtering by a coulmn within one of the joins. However, if I try to SELECT that coulmn, I am getting an Oracle error ORA-00947. I can even SELECT * and get ALL the columns back form ALL the tables I'm joing on, including the one that is not allowing me just to select it.
Has anyone ever seen anything like this before???
I appreciate your review and am hopeful for a reply.
Thanks.
PSULionRPJez....Not sure if I need to worry about proprietary stuff here...Here's the SQL and the column I'm trying to select is CDM_SUPPLIER_UTILITY.SUPPLIER_CD.
When I do that is when I get the ORA-00947 error. And our version is...
Oracle9i Enterprise Edition Release 9.2.0.8.0 - 64bit Production
SELECT CDM_CALENDAR.CALENDAR_DT,
CDM_OFFER.SUPPLIER_NAME,
CDM_SUPPLIER_UTILITY.SUPPLIER_CD,
ABS(SUM(CDM_MONEY.TRANSACTION_AMT))
FROM CDEDM.CDM_TRANSACTIONS CDM_TRANSACTIONS
INNER JOIN CDEDM.CDM_MONEY CDM_MONEY
ON CDM_MONEY.TRANSACTION_FK = CDM_TRANSACTIONS.TRANSACTION_GK_PK
INNER JOIN CDEDM.CDM_OFFER CDM_OFFER
ON CDM_OFFER.OFFER_GK_PK = CDM_MONEY.OFFER_FK
INNER JOIN CDEDM.CDM_CALENDAR CDM_CALENDAR
ON CDM_CALENDAR.CALENDAR_DT_PK = CDM_MONEY.TRANSACTION_DT_FK
INNER JOIN CDEDM.CDM_BILL_ACCOUNTS CDM_BILL_ACCOUNTS
ON CDM_BILL_ACCOUNTS.BILL_ACCT_GK_PK = CDM_MONEY.BILL_ACCOUNTS_FK
INNER JOIN CDEDM.CDM_SUPPLIER_UTILITY CDM_SUPPLIER_UTILITY
ON CDM_SUPPLIER_UTILITY.SUPPLIER_UTILITY_GK_PK = CDM_BILL_ACCOUNTS.SUPPLIER_FK
WHERE CDM_SUPPLIER_UTILITY.SUPPLIER_CD = 'MC2'
AND CDM_CALENDAR.CALENDAR_DT BETWEEN NEXT_DAY(trunc(SYSDATE-12),'Saturday')
AND NEXT_DAY(trunc(SYSDATE-5),'Saturday')
AND CDM_TRANSACTIONS.TRAN_DECODE IN
'Debit/Bill Installment Billing',
'Debit/Bill Electric Service',
'Debit by Transfer of Payment TO Uncollec',
'Debit Miscellaneous Electric',
'Credit for Transfer TO Uncollectible',
'Credit for Tranfer FROM Uncollectible',
'Credit Miscellaneous Electric',
'Credit Alteration',
'Credit Allowance',
'Bill Consumption On An Inactive Meter'
AND CDM_MONEY.TRANSACTION_LEVEL_CD IN
'A',
GROUP BY CDM_CALENDAR.CALENDAR_DT,
CDM_OFFER.SUPPLIER_NAME,
CDM_SUPPLIER_UTILITY.SUPPLIER_CD -
Select Query and Join Between int and Numeric(22)
I have two tables
tablea
Field1 int
tableb
Field1 Numeric(22)
I know this design is wrong but this is what I have ?
tablea contains about 12M records
Field1 in tablea is one to one related to Field1 in tableb
Now I have Select Query
Select tablea.* from tablea,tableb where tablea.field1=tableb.field1 and tableb.field2 > somrthing
Query here is
Does Join Between
int typeYes, avinash said rightly.
there is another way bit diffict.
use the indexes properly as available in the mseg table and mkpf table even then it is diffcult
else try using BAPI.
some bapi will give the entire details of the MATERAIL DOCUMENT
go to BAPI explorer tcode BAPI.
where you can find the BAPI name like the 'GET_LIST'.
Try this.
hope this will serve your purpose.
Thanks and regards
Ramchander Rao.K -
Hi All,
I had to modify the current select query coz its taking a lot of database time, please suggest the best solution for the below.
SELECT msegbukrs mkpfbudat mkpf~bldat
msegebeln mkpfxblnr mseg~mblnr
msegmjahr msegzeile mseg~xauto
msegparent_id msegwerks mseg~umwrk
msegumlgo msegparent_id ekko~reswk
msegwerks mseglgort mseg~matnr
msegerfmg msegerfme mseg~shkzg
msegsjahr msegsmbln mseg~smblp
msegcharg ekkobedat
INTO TABLE g_tbl_main
FROM mkpf JOIN mseg
ON mkpfmandt = msegmandt AND
mkpfmblnr = msegmblnr AND
mkpfmjahr = msegmjahr
JOIN ekko ON msegmandt = ekkomandt AND
msegebeln = ekkoebeln
JOIN likp ON mkpfxblnr = likpvbeln
CLIENT specified
WHERE mkpf~mandt = sy-mandt AND
mkpf~budat IN s_budat AND
ekko~bedat IN s_bedat AND
mseg~ebeln IN s_ebeln AND
mkpf~xblnr IN s_vbeln AND
likp~vstel IN s_vstel AND
ekko~reswk IN s_reswk AND
mseg~werks IN r_werks AND
mseg~lgort IN s_lgort AND
mseg~matnr IN s_matnr AND
mseg~smbln = space AND
mseg~bwart IN s_bwart AND
mseg~kzzug = c_true.Yes, avinash said rightly.
there is another way bit diffict.
use the indexes properly as available in the mseg table and mkpf table even then it is diffcult
else try using BAPI.
some bapi will give the entire details of the MATERAIL DOCUMENT
go to BAPI explorer tcode BAPI.
where you can find the BAPI name like the 'GET_LIST'.
Try this.
hope this will serve your purpose.
Thanks and regards
Ramchander Rao.K -
hi friends,
can we use where clause in select statement with inner join.
i am using following code which gives error (The column name "WERKS" has two meanings . .).
SELECT AMATNR ACHARG AERSDA BMENGE B~MEINS
FROM MCHA AS A INNER JOIN CHVW AS B
ON ACHARG = BCHARG
INTO TABLE T_OUTPUT1
WHERE WERKS = PLANT AND CHARG = P_CHARG.
thanks.Yes u can use where clause in select statement with inner join.
SELECT AMATNR ACHARG AERSDA BMENGE B~MEINS
FROM MCHA AS A INNER JOIN CHVW AS B
ON ACHARG = BCHARG
INTO TABLE T_OUTPUT1
WHERE WERKS = PLANT AND CHARG = P_CHARG.
" mention the table name in where condition also like awerks or bwerks.
egards
Rajendra -
hi all,
i have to extract data from 3 different tables.
is a single inner join better option or separate select statements ?
thanksHi,
If there are common key fields in the three tables, then inner join is a better option else its better to use for all entries to fetch the data.
If you want an example to join 3 tables, you can find it at this path in SAP
ABAPDOCU(Transaction)>ABAP Database Access>Open SQL>Read data>Inner Join.
you can find the following code*
DATA: BEGIN OF wa,
carrid TYPE spfli-carrid,
connid TYPE spfli-connid,
fldate TYPE sflight-fldate,
bookid TYPE sbook-bookid,
END OF wa,
itab LIKE SORTED TABLE OF wa
WITH UNIQUE KEY carrid connid fldate bookid.
SELECT pcarrid pconnid ffldate bbookid
INTO CORRESPONDING FIELDS OF TABLE itab
FROM ( ( spfli AS p
INNER JOIN sflight AS f ON pcarrid = fcarrid AND
pconnid = fconnid )
INNER JOIN sbook AS b ON bcarrid = fcarrid AND
bconnid = fconnid AND
bfldate = ffldate )
WHERE p~cityfrom = 'FRANKFURT' AND
p~cityto = 'NEW YORK' AND
fseatsmax > fseatsocc.
LOOP AT itab INTO wa.
AT NEW fldate.
WRITE: / wa-carrid, wa-connid, wa-fldate.
ENDAT.
WRITE / wa-bookid.
ENDLOOP.
Reward if helpfull
Regards,
Adithya M -
Need help SELECT wiht INNER JOIN
Hi,
I need the the entire record of the MVKE with the same vkorg as in the table YMMARKET. Why has the bellow Join syntex error. Thank you
SELECT *
FROM MVKE
INNER JOIN YMMARKET_CODE ON mvkevkorg = ymmarket_codevkorg
WHERE matnr = p_matnr.
ENDSELECT.Hello,
Do this:
DATA:
lt_mvke TYPE STANDARD TABLE OF MVKE.
SELECT <field1> <field2>
INTO TABLE lt_mvke
FROM MVKE AS M INNER JOIN YMMARKET_CODE AS Y ON m~vkorg = y~vkorg
WHERE matnr = p_matnr.
When using inner join you need to specify the fields.
I suggest you the following:
SELECT * FROM MVKE INTO TABLE lt_mvke
FOR ALL ENTRIES IN YMMARKET_CODE
WHERE matnr = p_matnr
AND vkorg = ymmarket_code-vkorg.
Regards, -
Performance tuning of select with inner join
Hi experts,
I need to improve the performanve in these two big selects, could you give me some tips, please?Thanks!
SELECT AWBELN BPOSNR ARFBSK AWFDAT ALIFRE AKNUMV
BZZ_TKNUM BKOWRR BZZ_VSART BZZ_DTABF
CTKNUM CVSART C~TDLNR
CDTABF CSHTYP C~SDABW
DTPNUM DVBELN
EERDAT EVSTEL EKUNNR EANZPK EBTGEW EGEWEI
E~LFDAT
INTO CORRESPONDING FIELDS OF TABLE GT_AGENCY
FROM WBRK AS A
INNER JOIN WBRP AS B
ON AWBELN = BWBELN AND
B~KOWRR EQ ''
INNER JOIN VTTK AS C
ON BZZ_TKNUM = CTKNUM
INNER JOIN VTTP AS D
ON CTKNUM = DTKNUM
INNER JOIN LIKP AS E
ON DVBELN = EVBELN
WHERE A~WBELN IN SO_WBELN AND
A~RFBSK IN SO_RFBSK AND
A~WFDAT IN SO_WFDAT AND
A~LIFRE IN SO_TDLNR AND
B~ZZ_VSART IN SO_VSART AND
B~ZZ_DTABF IN SO_DTABF AND
C~VSART IN SO_VSART AND
D~TKNUM IN SO_REBEL AND
D~VBELN IN SO_VBELN AND
E~ERDAT IN SO_ERDAT AND
E~VSTEL IN SO_VSTEL AND
E~KUNNR IN SO_KUNNR.
SORT GT_AGENCY BY TDLNR VSTEL TKNUM TPNUM VBELN.
DELETE ADJACENT DUPLICATES FROM GT_AGENCY
COMPARING TDLNR VSTEL TKNUM TPNUM VBELN.
IF NOT GT_AGENCY[] IS INITIAL.
SELECT VFKPTDLNR VFKPFKNUM VFKPFKPOS VFKPKNUMV VFSIKPOSN VFKPREBEL VFSIVBELN vfsivbtyp
INTO corresponding fields of TABLE GT_SHIPCOST
FROM VFKP
JOIN VFSI ON VFSIKNUMV = VFKPKNUMV
WHERE VFKP~TDLNR IN SO_TDLNR
AND VFKP~FKNUM IN SO_FKNUM
AND VFKP~FKPOS IN SO_FKPOS
AND VFKP~STBER IN SO_STBER
AND VFKP~FKPTY IN SO_FKPTY
AND ( VFSI~VBTYP = 'J'(S01) OR
VFSI~VBTYP = 'T'(S03) or
vfsi~vbtyp = 'a' ).
ENDIF.
Thanks a lot!
PatriciaHi
1) Dont use nested seelct statement
2) If possible use for all entries in addition
3) In the where addition make sure you give all the primary key
4) Use Index for the selection criteria.
5) You can also use inner joins
6) You can try to put the data from the first select statement into an Itab and then in order to select the data from the second table use for all entries in.
7) Use the runtime analysis SE30 and SQL Trace (ST05) to identify the performance and also to identify where the load is heavy, so that you can change the code accordingly
https://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/docs/library/uuid/5d0db4c9-0e01-0010-b68f-9b1408d5f234
1. Use Inner Joins
2. INTO TABLE
3. No nested loop
4. FOR ALL ENTRIES
5. Use as much of the key as possible
5. try to use primary or secondary keys in where condition. When using key fields, start with first key field.
6. Select only the fields you need for display/processing - avoid select *
Reward if useful
regards
Anji -
Error in select query using join
hi all
please help.
The follwing code givs this error....
select skb1-bukrs ska1-ktoks skb1-saknr skb1-waers skb1-xsalh skb1-xopvw skb1-xkres
into corresponding fields of table it_skab1
from ( skb1
OUTER JOIN ska1 on ska1-saknr=skb1-saknr ) .
*Error while executing....*
Program ZABHI_FIREPORT
"(" has no closing ")".
Please guide me for the correct syntax.
Thank u.hi,
use this code n check
tables: ska1,skb1.
data: begin of it_skab1 occurs 0,
bukrs like skb1-bukrs,
ktoks like ska1-ktoks,
saknr like skb1-saknr,
waers like skb1-waers,
xsalh like skb1-xsalh,
xopvw like skb1-xopvw,
xkres like skb1-xkres,
end of it_skab1.
select skb1~bukrs
ska1~ktoks
skb1~saknr
skb1~waers
skb1~xsalh
skb1~xopvw
skb1~xkres
from skb1 left outer join ska1 on skb1saknr = ska1saknr
into corresponding fields of table it_skab1 up to 10 rows.
loop at it_skab1.
write: / it_skab1-bukrs,it_skab1-ktoks,it_skab1-saknr,it_skab1-waers,it_skab1-xsalh,
it_skab1-xopvw,it_skab1-xkres.
endloop.
n let me knw is ur doubt cleared
rgds
shivraj
Edited by: ShivrajSinha on May 27, 2009 8:27 AM -
SELECT Query design with JOINS
Dear Users,
In one of our requirements, we have a SELECT query which joins a few tables together and selects a few fields from each table.
Example: Fields 1,2 and 3 from Table 1
Fields 4 and 5 from Table 2.
These fields are later displayed in the form of an ALV. However, the end user wants more fields on the output, let's say field 6 from Table 2. Due to this requirement, I have to amend the SELECT query to add field 6 of Table 2.
The above example is simple since it only involves 2 tables. However, in reality, we have a SELECT query with INNER JOINS on more than 6 tables and we don't want to change the code when someone asks for an additional field from one of these tables. Is there any way by which I can design my SELECT query (Using field symbols or dynamic selections etc) such that I don't have to amend the SELECT query and instead I should be able to maintain the field required by the user and it's source table name in a Z-Table and the SELECT automatically picks it up ? Thanks!
Vijaybetter you can create a view on your 6 or more tables and select the fields .
Use Select * from <view name> every time in a select statement.
If you need a additional column then just change the view , there is no need to change of your select query.
with regards
Edited by: Avenai on Jun 28, 2010 2:09 PM
Maybe you are looking for
-
I am using Visual studio 2008 and crystal report 2008 in a web application. I have problem in logging to the database from crystal report by applying the connection info for the runtime (Connect to ODBC DSN). I got this error: System.Runtime.InteropS
-
Is there a way to allow users of my Iweb site to sign up and receive an email when the site is updated? I tried to do this with an html snippet on my page, but the service defaults to the url for the widget instead of the url for my page. I think thi
-
Coldfusion 11 Windows Server 2012 R2 Both the Coldfusion admin and additonal site work fine on HTTP. As soon as I attempt to enable SSL websockets and install SSL certs, the Coldfusion 11 Application service will not start. I followed the steps below
-
Result Set fetch agonisingly slow
I am having sporadic trouble retrieving data from a ResultSet. I do not know how to tell if it is an Oracle problem or a JDBC problem. In a while( results.next() ) loop, for some result sets it pauses for several seconds after every 10 iterations. Th
-
IChat AV: Unable to chat after migrating to new computer
Hi all, I used Carbon Copy Cloner to migrate my entire drive to a new computer while my wife uses my Powerbook on a job out of town. Everything seems to be working fine--except that while we can chat with other folks, we cannot chat with each other.