Join Query Issue

Hi,
      I have issue in the following query when selecting SPART . If spart is selected , the results are not correct. Is there anything i am missing in the query.
  SELECT  amatnr aersda alaeda aprdha aspart bmaktx cprodh cvkorg cvtweg  cmvgr1  cmvgr2  cmvgr3   cmvgr4  cmvgr5
    INTO  CORRESPONDING FIELDS OF TABLE tbl_initdata
    FROM  ( ( mara AS a
              INNER JOIN makt AS b ON   amatnr = bmatnr    )
              INNer JOIN mvke AS c ON   amatnr = cmatnr     )
    WHERE a~mtart EQ p_mtart AND
          a~ersda IN s_ersda AND
          a~laeda IN s_laeda AND
          a~lvorm EQ p_lvorm AND
          a~spart IN s_spart AND
          c~vkorg IN s_vkorg AND
          c~vtweg IN s_vtweg AND
          c~lvorm EQ p_plvor.

Dear Friends,
           The query is not working when we use SELECT-OPTIONS for SPART. When using paramater its working fine.. For your more analysis, i am giving the Selection screen declarations and my Test Procedure.
SELECTION-SCREEN BEGIN OF BLOCK b1 WITH FRAME TITLE text-h01.
PARAMETERS:     p_mtart   TYPE mtart MEMORY ID mta OBLIGATORY
                                       DEFAULT 'FERT'.               "Material Type
SELECT-OPTIONS: s_ersda   FOR  mara-ersda   ,         "Created on
                s_laeda   FOR  mara-laeda   ,         "Changed on
                s_vkorg   FOR  mvke-vkorg,            "Sales Organization
                s_vtweg   FOR  mvke-vtweg,            "Distribution Channel
                s_spart   for  mara-spart.             "Division
SELECTION-SCREEN END OF BLOCK b1.
SELECTION-SCREEN BEGIN OF BLOCK b2 WITH FRAME TITLE text-h02.
PARAMETERS: p_lvorm AS CHECKBOX DEFAULT space,       "Marked for Deletion at Client Level
            p_plvor AS CHECKBOX DEFAULT space.       "Marked for Deletion at Plant Level
SELECTION-SCREEN END OF BLOCK b2.
HERE is the Select Query,
  SELECT amatnr aersda alaeda aprdha aspart bmaktx cprodh cvkorg cvtweg cmvgr1 cmvgr2 cmvgr3 cmvgr4 cmvgr5
INTO CORRESPONDING FIELDS OF TABLE tbl_initdata
FROM  mara AS a
INNER JOIN makt AS b ON  ( amatnr = bmatnr )
INNer JOIN mvke AS c ON  ( amatnr = cmatnr )
WHERE a~mtart EQ p_mtart AND
a~ersda IN s_ersda AND
a~laeda IN s_laeda AND
a~lvorm EQ p_lvorm AND
a~spart IN s_spart AND
c~vkorg IN s_vkorg AND
c~vtweg IN s_vtweg AND
c~lvorm EQ p_plvor.
TEST PROCEDURE ...
I am just selecting Material Type 'FERT', VKORG ,VTWEG and SPART.... Its returning a fixed value of 20 entries even when there are 1000+ entries in the Database.
Please put this code in your SAP environment and help me out...You can see this strange issue!!!
BTW, Thanks a lot for all SAP folks who are helping me out.

Similar Messages

  • Cartesian Join query optimization

    Hello Experts!
    I have a question about cartesian join query which might look a bit weird.
    Assume the SQL query like that:
    SELECT DISTINCT A.NAME
    FROM A, B, C;
    Here we have cartesian join for 3 tables A, B and C.
    It looks to me, in order to get the result for such a particular SQL tables/sets B and C need to be accessed only to ensure they return at least 1 row (otherwise result set is empty), query table A, but there is no actual need to join the data.
    If you run such a query Oracle is doing full table scans and actually joins the data.
    Yes, DBMS is doing exactly what you are asking for, but I wonder if there is any way (SQL hint or db parameter or anything else) to enforce more optimal access path here?
    Obvious solution to remove B and C tables from the SELECT statement is not acceptable. :-)
    Thank you!

    Your statement in the other thread indicates you don't understand how the BI prompts actually work because you say you want it to do something that doesn't make sense for it to do.
    Of course Product and Account levels will be constrained to the interval you specified. It wouldn't make sense for them not to be. Because that would mean returning data for based on product and account levels that has a different open data range than what you specified.
    All UI prompt dialogs I have seen use AND relationships between the parameters. If there are three parameters (A, B, C) then the ultimate relationship is 'A AND B AND C'; not 'A OR (B AND C)', 'A AND (B OR C)', 'A OR (B OR C).
    Unless the tool allows you to select OR relationships you need to use a separate dialog box (parameter dialog) for each condition set.:-)
    I understand how BI prompts work and basically agree on your comment, but there are two problems here:
    1. I need to convince the customer his original requirements are not valid. Customer want it to work different way and there are some reasons why.
    2. There are pretty large dimensions and fact tables used here, so when I choose filter criteria for the Product (which is small table) to populate/recalculate prompt values, large SR dimension and fact tables are joined too, and if there are Account dimension filters added, huge Account dimension will be added as well. This looks to be a bit sub-optimal for just populating the Product prompt values.
    Of course, technically this is solvable, but requires to put some extra effort and does not solve the 1st issue.
    That other link doesn't explain the sample code you posted in this thread. Post the actual query that is being generated and the query that you want to actually use.This is what is generated:
    >
    select distinct T311691.X_CUST_SUBTYPE as c1
    from
    WC_LOV_SR_AREA_H T311695,
    WC_LOV_PROD_H T311687,
    WC_LOV_CUST_TYPE_H T311691,
    W_SRVREQ_D T302384 /* Dim_W_SRVREQ_D */
    where ( T311687.LEV1 = 'Product X' and T311691.X_CUST_TYPE = 'Business' and T302384.OPEN_DT between TO_DATE('2012-03-01 00:00:00' , 'YYYY-MM-DD HH24:MI:SS') and TO_DATE('2012-03-31 00:00:00' , 'YYYY-MM-DD HH24:MI:SS') )
    order by c1
    >
    This is what is actually needed to query this data:
    >
    select distinct T311691.X_CUST_SUBTYPE as c1
    from
    WC_LOV_CUST_TYPE_H T311691
    where ( T311691.X_CUST_TYPE = 'Business' )
    order by c1

  • Adding a field to rhe join query

    Dear Friends,
    I need your help in adding a field to a join query.
    I have created a reort using join(SQVI). Now i want to add an addition field to that report. The issue is the field i am looking at is stored in structure. Is there any way i can add this field....
    Sanjay

    It is not possible here (in SQVI).
    you have to Go with Query.
    SQ02 using this Create infoset, add all the tables , here include that structure field, and then add the logic to populate the field.
    Now go to SQ01 and create Query.

  • Inner join query used with 7 Database tables

    HI All,
    In a report they used the Inner join Query with 6 Data base table..now there is a performance issue with at query.
    its taking so much of time to trigger that query. Please help how to avoid that performance issue for that.
    In that 2 database tables containing lakhs of records..
    According to my knowledge it can be avoided by using secondary indexs for those 2 database tables..
    and by replacing the Inner join Query with FOR ALL ENTRIES statement.
    i want how to use the logic by using FORALL ENTRIES statement for this..
    So, please give you proper suggestion to avoid this issue..
    Thanking you.
    Moderator message: Please Read before Posting in the Performance and Tuning Forum
    Edited by: Thomas Zloch on Oct 16, 2011 10:27 PM

    Hi,
    And what do you mean with "they used"? If "SAP used" then yo will need to ask a SAP for note
    FOR ALL ENTRIES is quite good described in help. Please search forum also.
    Without query it won't be possible to tell how it can be optimized, however you can try to use SE30/SAT and ST05. Maybe it will help you.
    BR
    Marcin Cholewczuk

  • Sql join query join

    Hi I have 3 tables.
    Table                   columns
    1. Buy                     buyer,sellername
    2. IM                      product,hdate,UOM,dept,sec,subsec
    3. stud                    dept,sec,subsecRequired O/P with columns as :
    buyer   product   dept  sec  subsec
    ---------------------------------------------------so please send me the join query for this.
    Thank you.

    I am getting the output with the above mentioned query as
    buyer   product  dept    class     subsecs
    90      glass    203     310      234
    120     glass    203     310      234
    354     glass    203     310      234
    435     belts    330     243      890
    435     belts    330     243      890
    ...like this I am getting the result...
    So please help me in this issue..
    Thank you.

  • Join Query hanging

    hi experts,
    please help on this, we have migrated database from 10g to 11.2.0.3 , Everything went sccessful but one of the simple join query hanging occasionally in new upgraded database. is there any known issue or anything need to add after migration for sqls?,also before migration its was executed without any issues. that query is joining and fetching from two more tables . is there any generic reason please provide that would be helpful to analyze, Thanks in Advance.

    why wasn't this discovered during testing prior to the upgrade?
    does new DB have current statistics?
    How do I ask a question on the forums?
    https://forums.oracle.com/forums/thread.jspa?threadID=2174552#9360002

  • How to get Hierarchical XML File from a Database Join Query !

    Hi,
    How can i get a Hierarchical XML File from a Database Join Query ?
    Any join query returns repeated values as below:
    BD17:SQL>select d.dname, e.ename, e.sal
    2 from dept d
    3 natural join
    4 emp e
    5 /
    DNAME ENAME SAL
    ACCOUNTING CLARK 2450
    ACCOUNTING KING 5000
    ACCOUNTING MILLER 1300
    RESEARCH SMITH 800
    RESEARCH ADAMS 1100
    RESEARCH FORD 3000
    RESEARCH SCOTT 3000
    RESEARCH JONES 2975
    SALES ALLEN 1600
    SALES BLAKE 2850
    SALES MARTIN 1250
    SALES JAMES 950
    SALES TURNER 1500
    SALES WARD 1250
    14 rows selected.
    We tried use DBMS_XMLQUERY to generate a xml file, but it was unable to get xml in Hierarchical format.
    <?xml version="1.0" encoding="ISO-8859-1" ?>
    - <ROWSET>
    - <ROW num="1">
    <DNAME>ACCOUNTING</DNAME>
    <ENAME>CLARK</ENAME>
    <SAL>2450</SAL>
    </ROW>
    - <ROW num="2">
    <DNAME>ACCOUNTING</DNAME>
    <ENAME>KING</ENAME>
    <SAL>5000</SAL>
    </ROW>
    - <ROW num="3">
    <DNAME>ACCOUNTING</DNAME>
    <ENAME>MILLER</ENAME>
    <SAL>1300</SAL>
    </ROW>
    - <ROW num="4">
    <DNAME>RESEARCH</DNAME>
    <ENAME>SMITH</ENAME>
    <SAL>800</SAL>
    </ROW>
    - <ROW num="5">
    <DNAME>RESEARCH</DNAME>
    <ENAME>ADAMS</ENAME>
    <SAL>1100</SAL>
    </ROW>
    - <ROW num="6">
    <DNAME>RESEARCH</DNAME>
    <ENAME>FORD</ENAME>
    <SAL>3000</SAL>
    </ROW>
    - <ROW num="7">
    <DNAME>RESEARCH</DNAME>
    <ENAME>SCOTT</ENAME>
    <SAL>3000</SAL>
    </ROW>
    - <ROW num="8">
    <DNAME>RESEARCH</DNAME>
    <ENAME>JONES</ENAME>
    <SAL>2975</SAL>
    </ROW>
    - <ROW num="9">
    <DNAME>SALES</DNAME>
    <ENAME>ALLEN</ENAME>
    <SAL>1600</SAL>
    </ROW>
    - <ROW num="10">
    <DNAME>SALES</DNAME>
    <ENAME>BLAKE</ENAME>
    <SAL>2850</SAL>
    </ROW>
    - <ROW num="11">
    <DNAME>SALES</DNAME>
    <ENAME>MARTIN</ENAME>
    <SAL>1250</SAL>
    </ROW>
    - <ROW num="12">
    <DNAME>SALES</DNAME>
    <ENAME>JAMES</ENAME>
    <SAL>950</SAL>
    </ROW>
    - <ROW num="13">
    <DNAME>SALES</DNAME>
    <ENAME>TURNER</ENAME>
    <SAL>1500</SAL>
    </ROW>
    - <ROW num="14">
    <DNAME>SALES</DNAME>
    <ENAME>WARD</ENAME>
    <SAL>1250</SAL>
    </ROW>
    </ROWSET>
    Thank you for some help.
    Nelson Alberti

    Hi,
    I wrote a general ABAP program which can be configured to grab contrent from an URL and post that content as a new PI message into the integration adapter .... from that point on normal PI configuration can be used to route it to anywhere ...
    It can be easily scheduled as a background job to grab content on a daily basis etc ...
    Regards,
    Steven

  • Deciphering column names in a join query using jdbc

    hi all....
    I am making a database adapter for a generic report generater. This adapter would be forming queries involing various tables. There are two ways of doing it . I fire an sql on parent table to get the keys and then go to child table for each one of them or i form a join query to get desired result.
    i want to go with the later approach where my query would be forming a join. The problem comes when table involved in this join has columns with the same name. for eg if a column "NOTE" is there in table A as well as table B on which i have a join. Resultset returns me with two "NOTE" columns and i cannot recognize which one belongs to which table.
    all API calls including getString("Note") seems to be referring to the first occurence of "Note" column.
    Also getTableName() and getSchemaName() APIs on resultsetMetadata doesnt return in anything in case of joins.
    Any pointers would be most appreciated.
    cheers
    vivek

    thanks for suggesting this solution ... though i had thought of the same onece .... unfortunately i cannot implement something like this coz out of the result set i have to instantiate an object hierarchy depending on the schema ....
    this also puts me in a doubt whether i can use join in my case.
    for eg ... .
    lets say we have a customer talbe and and address table which has one to many relationship .... one contact can have multiple addresses.
    Assuming a contanct "Joe Bloggs" having 3 addresses ...a query like following
    select contact.firstname contactfirstname , address.streetname addressstreetname from contact , address where contact.contactid = address.contactid
    this would return me 3 rows and i can also recognize various columns with their aliases ..
    but i would lose an important fact that i have to create one java object for contact class and 3 instances for addresses which i have to return finally.
    this means that i would like to return an object hierarchy with one contact object and 3 address object underneath it linked with contactid.
    Any other suggestions after reading the complete requirement are most welcome ...sorry for not puting the entire thing at first.
    i guess the only soln left is to visit contact and address table separately. :(

  • Dataset query issues twice if the dataset is connected to matrix and used in multilookup function

    hello everybody.
    could not find any information if this is an intended behavior:
    dataset query issues twice if the dataset is connected to matrix and used in multilookup function
    parameters in both queries are the same
    ssrs: 2008 r2, sharepoint 2010 integrated
    sharepoint 2010: september 2014 cu
    thanks in advance
    Sergey Vdovin

    Hello, Wendy.
    I prepared a very empty sample report for you to demonstrate the problem - with this report, i hope, there is no place to discuss the shrinking of time data retrieval.
    There is one dataset, one parameter and one lookup function. The query is executed twice.
    <?xml version="1.0" encoding="utf-8"?>
    <Report xmlns:rd="http://schemas.microsoft.com/SQLServer/reporting/reportdesigner" xmlns:cl="http://schemas.microsoft.com/sqlserver/reporting/2010/01/componentdefinition" xmlns="http://schemas.microsoft.com/sqlserver/reporting/2010/01/reportdefinition">
    <AutoRefresh>0</AutoRefresh>
    <DataSources>
    <DataSource Name="DataSource1">
    <DataSourceReference>http://t005/ProjectBICenter/DocLib/IntegrationDBVdovin.rsds</DataSourceReference>
    <rd:SecurityType>None</rd:SecurityType>
    <rd:DataSourceID>7e554344-d6c2-48a5-a7f4-1d24608cb4b5</rd:DataSourceID>
    </DataSource>
    </DataSources>
    <DataSets>
    <DataSet Name="DataSet1">
    <Query>
    <DataSourceName>DataSource1</DataSourceName>
    <CommandText>select 1 as temp, '$' as tempname</CommandText>
    <rd:UseGenericDesigner>true</rd:UseGenericDesigner>
    </Query>
    <Fields>
    <Field Name="temp">
    <DataField>temp</DataField>
    <rd:TypeName>System.Int32</rd:TypeName>
    </Field>
    <Field Name="tempname">
    <DataField>tempname</DataField>
    <rd:TypeName>System.String</rd:TypeName>
    </Field>
    </Fields>
    </DataSet>
    </DataSets>
    <ReportSections>
    <ReportSection>
    <Body>
    <ReportItems>
    <Textbox Name="ReportTitle">
    <CanGrow>true</CanGrow>
    <KeepTogether>true</KeepTogether>
    <Paragraphs>
    <Paragraph>
    <TextRuns>
    <TextRun>
    <Value>=Lookup(1,Fields!temp.Value,Fields!tempname.Value,"DataSet1")</Value>
    <Style>
    <FontFamily>Verdana</FontFamily>
    <FontSize>20pt</FontSize>
    </Style>
    </TextRun>
    </TextRuns>
    <Style />
    </Paragraph>
    </Paragraphs>
    <rd:WatermarkTextbox>Title</rd:WatermarkTextbox>
    <rd:DefaultName>ReportTitle</rd:DefaultName>
    <Top>0mm</Top>
    <Height>10.16mm</Height>
    <Width>139.7mm</Width>
    <Style>
    <Border>
    <Style>None</Style>
    </Border>
    <PaddingLeft>2pt</PaddingLeft>
    <PaddingRight>2pt</PaddingRight>
    <PaddingTop>2pt</PaddingTop>
    <PaddingBottom>2pt</PaddingBottom>
    </Style>
    </Textbox>
    </ReportItems>
    <Height>57.15mm</Height>
    <Style>
    <Border>
    <Style>None</Style>
    </Border>
    </Style>
    </Body>
    <Width>152.4mm</Width>
    <Page>
    <PageFooter>
    <Height>11.43mm</Height>
    <PrintOnFirstPage>true</PrintOnFirstPage>
    <PrintOnLastPage>true</PrintOnLastPage>
    <Style>
    <Border>
    <Style>None</Style>
    </Border>
    </Style>
    </PageFooter>
    <PageHeight>29.7cm</PageHeight>
    <PageWidth>21cm</PageWidth>
    <LeftMargin>2cm</LeftMargin>
    <RightMargin>2cm</RightMargin>
    <TopMargin>2cm</TopMargin>
    <BottomMargin>2cm</BottomMargin>
    <ColumnSpacing>0.13cm</ColumnSpacing>
    <Style />
    </Page>
    </ReportSection>
    </ReportSections>
    <ReportParameters>
    <ReportParameter Name="ReportParameter1">
    <DataType>String</DataType>
    <DefaultValue>
    <Values>
    <Value>1</Value>
    </Values>
    </DefaultValue>
    <Prompt>ReportParameter1</Prompt>
    <ValidValues>
    <DataSetReference>
    <DataSetName>DataSet1</DataSetName>
    <ValueField>temp</ValueField>
    <LabelField>tempname</LabelField>
    </DataSetReference>
    </ValidValues>
    </ReportParameter>
    </ReportParameters>
    <rd:ReportUnitType>Mm</rd:ReportUnitType>
    <rd:ReportServerUrl>http://t005/ProjectBICenter</rd:ReportServerUrl>
    <rd:ReportID>cd1262ef-eca7-4739-a2ce-d3ca832d5cd6</rd:ReportID>
    </Report>
    Sergey Vdovin

  • How can I perform this kind of range join query using DPL?

    How can I perform this kind of range join query using DPL?
    SELECT * from t where 1<=t.a<=2 and 3<=t.b<=5
    In this pdf : http://www.oracle.com/technology/products/berkeley-db/pdf/performing%20queries%20in%20oracle%20berkeley%20db%20java%20edition.pdf,
    It shows how to perform "Two equality-conditions query on a single primary database" just like SELECT * FROM tab WHERE col1 = A AND col2 = B using entity join class, but it does not give a solution about the range join query.

    I'm sorry, I think I've misled you. I suggested that you perform two queries and then take the intersection of the results. You could do this, but the solution to your query is much simpler. I'll correct my previous message.
    Your query is very simple to implement. You should perform the first part of query to get a cursor on the index for 'a' for the "1<=t.a<=2" part. Then simply iterate over that cursor, and process the entities where the "3<=t.b<=5" expression is true. You don't need a second index (on 'b') or another cursor.
    This is called "filtering" because you're iterating through entities that you obtain from one index, and selecting some entities for processing and discarding others. The white paper you mentioned has an example of filtering in combination with the use of an index.
    An alternative is to reverse the procedure above: use the index for 'b' to get a cursor for the "3<=t.b<=5" part of the query, then iterate and filter the results based on the "1<=t.a<=2" expression.
    If you're concerned about efficiency, you can choose the index (i.e., choose which of these two alternatives to implement) based on which part of the query you believe will return the smallest number of results. The less entities read, the faster the query.
    Contrary to what I said earlier, taking the intersection of two queries that are ANDed doesn't make sense -- filtering is the better solution. However, taking the union of two queries does make sense, when the queries are ORed. Sorry for the confusion.
    --mark                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • Help with Inner Join query in SQL

    Hope someone can help with this, as this is quite an involved project for me, and I'm just about there with it.
    My table structure is :
    table_packages
    packageID
    package
    packageDetails
    etc
    table_destinations
    destinationID
    destination
    destinationDetails
    etc
    table_packagedestinations
    packageID
    destinationID
    ..so nothing that complicated.
    So the idea is that I can have a package details page which shows the details of the package, along any destinations linked to that package via the packagedestinations table.
    So this is the last part really - to get the page to display the destinations, but I'm missing something along the way....
    This is the PHP from the header, including my INNER JOIN query....
    PHP Code:
    <?php
    $ParampackageID_WADApackages = "-1";
    if (isset($_GET['packageID'])) {
      $ParampackageID_WADApackages = (get_magic_quotes_gpc()) ? $_GET['packageID'] : addslashes($_GET['packageID']);
    $ParamSessionpackageID_WADApackages = "-1";
    if (isset($_SESSION['WADA_Insert_packages'])) {
      $ParamSessionpackageID_WADApackages = (get_magic_quotes_gpc()) ? $_SESSION['WADA_Insert_packages'] : addslashes($_SESSION['WADA_Insert_packages']);
    $ParampackageID2_WADApackages = "-1";
    if (isset($_GET['packageID'])) {
      $ParampackageID2_WADApackages = (get_magic_quotes_gpc()) ? $_GET['packageID'] : addslashes($_GET['packageID']);
    mysql_select_db($database_connPackages, $connPackages);
    $query_WADApackages = sprintf("SELECT packageID, package, costperpax, duration, baselocation, category, dateadded, agerange, hotel, educational_tours, field_trips, corporate_outings, plant_visits, budget_package, rollingtours, teambuilding, description, offer FROM packages WHERE packageID = %s OR ( -1= %s AND packageID= %s)", GetSQLValueString($ParampackageID_WADApackages, "int"),GetSQLValueString($ParampackageID2_WADApackages, "int"),GetSQLValueString($ParamSessionpackageID_WADApackages, "int"));
    $WADApackages = mysql_query($query_WADApackages, $connPackages) or die(mysql_error());
    $row_WADApackages = mysql_fetch_assoc($WADApackages);
    $totalRows_WADApackages = mysql_num_rows($WADApackages);
    $colname_educationalDestinations = "1";
    if (isset($_GET['PackageID'])) {
      $colname_educationalDestinations = (get_magic_quotes_gpc()) ? packageID : addslashes(packageID);
    mysql_select_db($database_connPackages, $connPackages);
    $query_educationalDestinations = sprintf("SELECT * FROM destinations INNER JOIN (packages INNER JOIN packagedestinations ON packages.packageID = packagedestinations.packageID) ON destinations.destinationID = packagedestinations.destinationID WHERE packages.packageID = %s ORDER BY destination ASC", GetSQLValueString($colname_educationalDestinations, "int"));
    $educationalDestinations = mysql_query($query_educationalDestinations, $connPackages) or die(mysql_error());
    $row_educationalDestinations = mysql_fetch_assoc($educationalDestinations);
    $totalRows_educationalDestinations = mysql_num_rows($educationalDestinations);
    ?>
    And where I'm trying to display the destinations themselves, I have : 
    <table>
            <tr>
                     <td>Destinations :</td>
                </tr>
               <?php do { ?>
            <tr>
                 <td><?php echo $row_educationalDestinations['destination']; ?></td>
            </tr>
            <?php } while ($row_educationalDestinations = mysql_fetch_assoc($educationalDestinations)); ?>
    </table>
    If anyone could have a quick look and help me out that would be much appreciated - not sure if its my SQL at the top, or the PHP in the page, but either way it would be good to get it working. 
    Thanks.

    First off, you need to get the database tables so that there is a relationship between them.
    In fact, if there is a one to one relationship, then it may be better to store all of your information in one table such as
    table_packages
    packageID
    package
    packageDetails
    destination
    destinationDetails
    etc
    If there is a one to many relationship, then the following would be true
    packages
    packageID
    package
    packageDetails
    etc
    destinations
    destinationID
    packageID
    destination
    destinationDetails
    etc
    The above assumes that there are many destinations to one package with the relationship coloured orange.
    Once you have the above correct you can apply your query as follows
    SELECT *
    FROM packages
    INNER JOIN destinations
    ON packages.packageID = destinations.packageID
    WHERE packages.packageID = %s
    ORDER BY destination ASC
    The above query will show all packages with relevant destinations

  • Problem getting results with no unique key in a joined query

    I created a descriptor to do a joined query, which generated a query in log as:
    Select t0.empID,t1.empID, t1.phone from Emp t0, Phone t1
    where t0.empId=t1.empId and t0.empId=1001
    When I run it, I got the result as:
    1001,1001,9999999
    1001,1001,9999999
    The correct result should be (I copy and paste the query from log into SQL-Plus):
    1001,1001,9999999
    1001,1001,1234455
    I suspect this is caused by Toplink caching objects by primary key. I wonder if anybody has a solution for this.
    My descriptor is created using WorkBench. Emp is the primary table, Phone as additional table linked by foreignKey empId.
    The join is implemented by modifying the descriptor as the following:
    ExpressionBuilder builder = new ExpressionBuilder();
    descriptor.getQueryManage()
    .setMultipleTableJoinExpression(
    builder.getField("EMP.EMPID").equal(
    builder.getField("EMP.EMPID")));
    descriptor.disableCacheHits();
    I'd really appreciate your help.

    I am implementing a people search function. The batch reading is quite expensive if toplink does a read query for every person. A customized query requires only one database access, the other way may requires hundreds.
    I don't want to use the cache either in this case because the database is also accessed by legacy system which cann't notify toplink any updates.
    I opened a TAR on this and the solution I got is to use ReportQuery rathen than ReadAllQuery. The only problem here is that now I have to map the query result to my class manually.

  • How to build table join query in Jdeveloper

    Hi,
    Can someone tell me how to build table join query in Jdeveloper's Expression Builder UI?

    [Is it possible to create a table of contents in Crystal Reports?|http://www.sdn.sap.com/irj/servlet/prt/portal/prtroot/com.sap.km.cm.docs/oss_notes_boj/sdn_oss_boj_erq/sap(bD1lbiZjPTAwMQ==)/bc/bsp/spn/scn_bosap/notes%7B6163636573733d36393736354636443646363436353344333933393338323636393736354637333631373036453646373436353733354636453735364436323635373233443330333033303331333233313335333133303330%7D.do]

  • Filter on "---" in Left Outer Join Query

    Hi guys,
    very basic question but I have not found an answer, yet. I built an left outer join MDO query and need to select all those dataset that did not find a "partner", that is fields are set to "---". However, I do not manage to filter on '---', NULL...
    When using SQL, it appears to be a String "---" but in MDO???

    Hey guys, found out that IS NULL needs to be used in query. Anyway, it appears to cause problems somewhere else.
    I placed an IS NULL filter expression inside a join query but query did not return any results when called in by transaction. After removing this line, both NULL and NOT NULL data were returned. When used in test mode, IS NULL was working fine...

  • Left outer join query

    Hi Experts,
        I am facing a problem with left outer join query. Am using one standard table and ztable for this join. My problem is values are not extracted from the Ztable.
    Query:
          SELECT  b~lifnr b~belnr b~gjahr b~xblnr b~shkzg b~blart b~zfbdt b~budat b~wrbtr
             b~wskto b~zlspr s~EXTRACT_STATUS s~maturity_date FROM bsik AS b
             LEFT OUTER JOIN zprm_rvne_sapdoc AS s
             ON s~belnr  EQ  b~belnr
             AND s~gjahr EQ b~gjahr
             INTO CORRESPONDING FIELDS OF TABLE it_join
                WHERE b~zlsch = p_zlsch
                AND b~xblnr IN so_invno
                ORDER BY b~lifnr b~xblnr.
    I have all entries of BSIK table in Ztable with extract status as Y but this query is not fetching extract status and maturity date of ztable so it is blank in the internal table.
    Need solution.
    Regards
    Sridevi S

    Hi,
    see the sample wiki for writing the Left outer join
    http://wiki.sdn.sap.com/wiki/display/Snippets/EmployeeInfotype0000to9999ChangeHistory
    Specifying Two or More Database Tables as a Left Outer Join
    The left outer join, on the other hand, reads lines from the left-hand database table or join even if there is no corresponding line in the right-hand table.
    SELECT...
      FROM <tab> LEFT [OUTER] JOIN <dbtab> [AS <alias>] ON <cond>
           <options>
    <tab> and <dbtab> are subject to the same rules and conditions as in an inner join. The OUTER addition is optional. The tables are linked in the same way as the inner join with the one exception that all lines selected from <tab> are included in the final selection. If <dbtab> does not contain any lines that meet the condition <cond>, the system includes a single line in the selection whose columns from <dbtab> are filled with null values.
    In the left outer join, more restrictions apply to the condition <cond> than in the inner join. In addition to the above restrictions:
    EQ or = is the only permitted relational operator.
    There must be at least one comparison between columns from <tab> and <dbtab>.
    The WHERE clause may not contain any comparisons with columns from <dbtab>. All comparisons using columns from <dbtab> must appear in the condition <cond>.
    If we have two tables named stud1,stud2 with the following data
    Stud1: id Name stud2: id Name
    1 xxx 1 aaa
    2 yyy 2 bbb
    3 zzz 4 ccc
    4 www 6 ddd
    When we use Left Outer Join we get the output as:
    1 aaa
    2 bbb
    3 <Null>
    4 ccc
    When we use Right Outer Join we get the output as:
    1 aaa
    2 bbb
    4 ccc
    <Null> ddd
    When we use Full Outer Join we get the output as:
    1 aaa
    2 bbb
    3 <Null>
    4 ccc
    <Null> ddd
    Prabhudas

Maybe you are looking for