Query to pull data from 2 different tables

Hi so currently I am using VS2008 and am using a DNN module to pull information based on a specific Article on our website. On the home page I am currently displaying the Title, Summary, Date and Author of the article. Currently under our feature Stories section of the site http://prepsonthenet.com/dnn/Home/tabid/386/Default.aspx the Title, Summary and Date, Author are being displayed for the top 8 articles that contain images. I was able to combine the 'Author' and Article table to display the 'AuthorName' for the first 8 images. That code is below:
strQueryArticleFirst.Append("select top 4 ArticleID,Title,Summary,[Text],");
strQueryArticleFirst.Append("(SELECT NAME FROM AUTHOR AU WHERE AU.AUTHORID = Article.AUTHORID) AS AUTHORNAME, ");
strQueryArticleFirst.Append("Convert(varchar(50),date,110)as [Date] from article");
strQueryArticleFirst.Append(" WHERE CategoryID=27 AND State='WI' AND deleted is null ");
Within this we have a strQueryArticleSecond which displays the next 6 stories without images: http://prepsonthenet.com/dnn/Home/tabid/386/Default.aspx
The code is a bit different here though and I can't seem to figure out how to link this back up to grab the 'AuthorName'
strQueryArticleSecond.Append("SELECT * FROM(");
strQueryArticleSecond.Append("select top 4 * from( ");
strQueryArticleSecond.Append("select top 8 * from article ");
strQueryArticleSecond.Append("where CategoryID=27 AND State='WI' and deleted is null ");
I get what the strQueryArticleSecond and how it is grabbing all the fields that were used in strQueryArticleFirst. I am just wondering how to re-link the AuthorName is this strQueryArticleSecond. Any help is appreciated. Thanks!

Sarangan,
Is there a way to get these data in a single
select query.Yes, use the "union" operator. See the "Oracle SQL Reference" for more details. It is available from here:
http://tahiti.oracle.com
Good Luck,
Avi.

Similar Messages

  • Selecting data from two different tables.

    Do we need to use join two tables with primary/foreign key while trying to use select statement for getting data from those to table.? If no who can i go about do it.

    872959 wrote:
    If i am using From clause to get data from two different tables, is it necessary that both tables have column of identical data in them.In general, they ought to (or you need to join in a third table that tells you how to map rows from one table to rows of the other table).
    It is not strictly necessary that there be any join condition between tables. If you don't provide a join condition, Oracle has to do a Cartesian product. That means that if there are n rows in one table and m rows in the other, the result set will have n * m rows. It is very rarely a good idea to write queries that do Cartesian products but it does occasionally happen.
    Justin

  • Having total brain fart - pulling data from two differnt tables

    Good morning,
    I am completely having a blonde moment here.
    My main select statement can pull all the data I need from one table however I need to define my result set by date range and the date data is held in another table. I am trying to remember how to write my statement to pull data from two tables in the same database.
    I haven't written query in a couple of years and was self taught previously - I need data our report management program cannot produce.
    Any help would be fantastic! Thank you :-)
    Dez
    Edited by: user10773439 on Jan 8, 2009 8:12 AM

    Here is the pseudo sql.
    select columns_from_table_a, columns_from table_b
    from table_a a,
    table_b
    where a.common_column = b.common_column
    and b.date_column > = <startdate>
    and b.date_column < <end_date>+1;
    --Dont forget to_date your date values                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Help Required -- Can we use SQL Query to READ data from SAP MDM Tables

    Hi All,
    Please help.........
    Can we use SQL Query to READ(No Creation/Updation/Deletion  just Read) Data from SAP MDM tables directly, without using MDM Syndicator.
    Or direct SQL access to SAP MDM tables is not possible. Only through MDM Syndicator can we export data.
    Thanks in Advance
    Regards

    All the tables you create in Repository comes under A2i_CM_Tables in Database named as your repository name. So the tables names are fields of table A2i_CM_Tables. Now i tried it but cant make it.
    Now, I dont think its possible to extract all fields in tables and there values using select query. May be pure sql guy can do that or not.
    But there is no relation of data extraction and syndicator. Data is viewed in Data Manager. and you can also store data in a file from DM also.
    BR,
    Alok

  • Getting Data from 2 different table and saving it in the third table

    Hi,
    My question is i have 2 different table where the data is stored. And Nothing is at Level0 and i don't need it.
    Table A will be at Level1, this is a scroll and depending on this value the level2 grid will be populated with the values.
    Say for example Table A is groups; data e.g., Cars, MotorBike etc
    Table B will have the data for Group Cars: Holden, Toyota, Honda etc., MotorBike: Honda, Suzuki, Yamaha etc.,
    Now lets say there are 3 divisions in the company AA , BB
    Division AA has been allocated group Cars only
    Division BB has been Allocated Both Cars and MotorBikes.
    To do this i have used a query view where depending on the Division i choose the group and then i get the required fileds.
    Now my Problem is that i need to save this data in table C but on the ad-hoc basis can't write a query with in the code to do that.
    tried using work record on the scroll but i cant do that as well. Any Suggestions?
    One more thing when the Page open this data should be pre-populated on the page depending on the division, the user will not be able to select anything from the prompt.
    Edited by: 952330 on Aug 12, 2012 8:32 PM

    I hope I can clarify:
    For our purposes here:
    Table 1 = "Step 2 - Product Sizes"
    Table 2 = "Option id Master"
    Table 3 = "Export - Product Info"
    Table 1:
    The user would enter values for "productcode," "Horz," and "Vert"
    "Size" would auto fill based on values in Horiz and Vert (I have this taken care of already).
    Table 2: This is a completely static table that I want to search against. - Data from other tables in the doc does not alter or change the data in this doc.
    We just want to look at table 2. Find the existing value in "table 2 : size" column that matches the "table 1 : size" column  and then pull the "optionids" and "productprice" from that row.
    Can the value from "Table 1 : Size" be used as a search term in "Table 2 : Size?"
    Table 3: The user does not enter any values on this table. 
    "productcode" is pulled from table 1 - "Table 1 :: A5" = "Table 3 :: A5"
    "optionids" and "productprice" are pulled from Table 2 columns "D" and "E" - however we do not know which Table 2 row it is pulling from until we enter data in Table 1.
    As I'm writing this I'm realizing that
    A. this is probably really confusing to you.
    B. this may be impossible inside of numbers.
    If you have some other method that would facilitate the same out come but be structured differently please let me know.
    --- maybe to help you understand further what I am doing here is my current workflow:
    I record the size of a piece of art.
    Then I manually go to my "Option id Master" and find the same size.
    I then copy the corresponding "optionids" and "productprice" cells. (these options control the prices displayed on my website)
    I got to my "Export - Product Info" table and paste the values in the corresponding cells.
    I was hoping to automate this as it takes a long time when you have hundreds of products.
    Thanks for the help!

  • Confirmed Dimensions. OBIEE Not able to pull data from two fact tables.

    Hi Experts,
    I have a very simple set up of Star Schema with two fact tables and 1 dimension. Both fact tables joined to the dimension at the same level.
    When i pull a column from both fact tables and the dimension table in OBIEE, it has to create simple SQL like below:
    select FACT1.column1,
    Fact2.Column1,
    Dim.Column1
    from FACT1, FACT2, DIM
    where FACT1.ID = DIM.ID and FACT2.ID = DIM.ID
    but instead it creating a query in a very complex way:
    select case  when D1.c2 is not null then D1.c2 when D2.c2 is not null then D2.c2 end  as c2,
         D1.c1 as c3,
         D2.c1 as c4
    from
         (select FACT1.Column1 as c1,
                   DIM.Column1 as c2
              from
                   DIM T1287863,              
                   FACT1 T1287945              
       where  (DIM.ID = FACT1.ID)
           ) D1 full outer join (
            select FACT2.Column1 as c1,
                   DIM.Column1 as c2
              from
                   DIM,              
                   FACT2
              where  ( DIM.ID = FACT2.ID)
         ) D2 On isnull(D1.c2 , '1') = isnull(D2.c2 , '1') and isnull(D1.c2 , '2') = isnull(D2.c2 , '2')
    I even tried setting the levels for both the fact tables and it still creates the query in avove way. Any thoughts on this will be vary helpful.

    Subramanian,
    see below the code we're using for the RFM.
    on the ct_containers table i'm passing a line, and its getting updated after the call.
    on the ct_errors table i just want to receive the errors and i only receive the line, we add manually there ('Serious error with validation code').
    kr, achim
    FUNCTION zbapi_ra_validations .
    *"*"Local Interface:
    *"  IMPORTING
    *"     VALUE(IS_RA_SCREEN) TYPE  ZBAPI_S_RA_SCREEN
    *"  CHANGING
    *"     VALUE(CT_ERRORS) TYPE  ZRA_T_ERRORS
    *"     VALUE(CT_CONTAINERS) TYPE  ZRA_T_CONT_IP
      DATA:
        lo_badi_handle TYPE REF TO zra_validation_rule,
        ls_error       TYPE zra_s_error.
      GET BADI lo_badi_handle.
      TRY.
          CALL BADI lo_badi_handle->validate_rules
            EXPORTING
              is_screen_flds = is_ra_screen
            CHANGING
              ct_containers  = ct_containers
              ct_errors      = ct_errors.
        CATCH zcx_ra.
          ls_error-message = 'Serious error with validation code'.
          APPEND ls_error TO ct_errors.
      ENDTRY.
    ENDFUNCTION.
    if i call this rfm in SE37 the ct_errors table is populated with all errors and the manually created line.
    Message was edited by: Achim Hauck

  • Adding two column data  from two different tables.

    Hi, I have two tables i want to add two column with same id and put it in third table
    T1 is
    id Value
    1 50
    2 100
    3 500
    4 75
    T2 is
    id Value
    3 -20
    4 80
    5 -30
    6 -10
    I want the out put as
    1 50
    2 100
    3 480
    4 155
    5 -30
    6 -10
    i have written
    select a.id,a.value+b.value from t1 a,t2 b where a.id=b.id(+)
    this is not giving me the id's from t2.

    select id, sum(value) from
    (Select id,value from t1
    union
    select id ,value from t2
    )group by id;

  • 1 Graph from 2 different tables?

    I'm trying to build some bar charts with two matching data sets that are in two different tables (they're big data sets). I don't want to have to copy the specific data I want from each Table into a 3rd table just to build a chart with it. Can I use data from two different tables in the same chart? i.e. the data looks like this in the chart but is in two different tables?
    Table1 Table2
    Data 20 25
    Data 35 22
    Data 36 27...
    Does this question make sense? Thanks for any help.
    Message was edited by: Aaron Smith6
    Message was edited by: Aaron Smith6

    If I understand well the User Guide, we may chart datas from different tables BUT it works with rows of different tables, not with columns of different tables.
    +• To add a chart based on data in more than one table, first select a single table or contiguous range of cells and create a chart, then click Charts in the toolbar, and choose a chart type. Select the chart and hold down the Command key while clicking or dragging cells in another table to add their data to the chart.+
    Yvan KOENIG (from FRANCE vendredi 9 janvier 2009 21:37:41)

  • Newbie: how to pull data from different data bases to a central location

    Hello,
    I have no experience at all in Oracle; just in MySQL, PostgreSQL, Firebird for simple applications. I have this project where my Client wants to extract data from related 5 tables, from 12 databases in different locations. Table structure in all 12 locations are the same, and I need to consolidate information for reporting purposes. I was planning in developing a Delphi application for this purpose, yet maybe with pure Oracle SQL or Oracle tools can I automate this?
    Thank you

    Please clarify your term "database".Instance of an Oracle database, one in each of the 12 locations.
    Are the computers in all these locations available via Internet?My client can see all 12 databases from an Oracle database manager; I still have to investigate if its through Internet or private WAN.
    What RDBMS are all these data sources?I have yet to verify the precise Oracle version, yet I know its an old one: 7 or 9. Will confirm it.
    What flavor of RDBMS is the target data repository?Same as previous question
    Is this a 1 shot data load or an ongoing requirement to consolidate "new" data into repository?The require to pull data automatically, maybe a batch process done by night.

  • Pulling data from table to a flat file

    hi all,
    Good day to all,
    Is there any script which i can use for pulling data from tables to a flat file and then import that data to other DB's. Usage of db link is restricted. The db version is 10.2.0.4.
    thanks,
    baskar.l

    Is there any script which i can use for pulling data from tables to a flat file and then import that data to other DB'sFlat file is adequate only from VARCHAR2, NUMBER, & DATA datatypes.
    Other datatypes present a challenge within text file.
    A more robust solution is to use export/import to move data between Oracle DBs.

  • Pull data from a table in HTML format from external URL into a Servlet

    How do I pull data from existing website html table into a Servlet?
    I will need to pull the data into a servlet. So, the servelet will need to go to the URL and get the data and save them as variables.
    I know I will need an array to store the data. I just dont know how to call the URL and have the servelet search the site for the <table> </table>.
    I will later use this to save to a database.
    Thanks
    Edited by: DJMegabit on Apr 14, 2010 7:36 PM

    Maybe give us more details about what exactly You'd like to achieve. I guess that there might be better solutions to the problem.

  • Is it possible to show data from two different sql tables?

    Is it possible to show data from two different sql tables? Either to show combined data by using a join on a foreign key or showing a typical master detail view?
    I have one table With data about a house, and another table With URL's to images in the blob. Could these two be combined in the same Gallery?
    Best regards Terje F - Norway

    Hi Terje,
    If you have a unique key, you could use one of the following functions for your scenarios:
    If you only have one image per house, you can use LookUp:
    http://siena.blob.core.windows.net/beta/ProjectSienaBetaFunctionReference.html#_Toc373745501
    If you have multiple images per house, you can use Filter:
    http://siena.blob.core.windows.net/beta/ProjectSienaBetaFunctionReference.html#_Toc373745487
    Thanks
    Robin

  • Using ABAP DATA FLOW to pull data from APO tables

    I am trying to use an ABAP Data flow to pull data from APO and receive error 150301. I can do a direct table pull and receive no error, but when I try to put it in an ABAP data data flow I get the issue. Any help would be great.

    Hi
    I know you "closed" this, however someone else might read it so I'll add that when you use an ABAP dataflow, logic can be pushed to ECC - table joins, filters, etc.  (Which can be seen in the generated ABAP).
    Michael

  • UNIQUE Problem in pulling DATA from DATA base table to internal table

    Dear Experts,
    I am new to ABAP. I have a very basic question but looks a quite puzzling one to me. Hemnce I am posting it here.
    I am facing an unique problem in pulling data from database table and populating that data into internal table for further use.
    The data in the database table "Zlt_mita" with fields M1 (Employee Name, Type: Char20) and M2 (Employee Code, Type Char7) are:
    Plz refer the screenshot in the attached file:
    My Code:
    1) When I try to pull data from Dbase table by taking M2 as parameter.
         This code is succcessful and I am able to populate data in internal table it_dat.
    TYPES: Begin Of ty_DAT,
                     M1   TYPE  Zlt_mita-M1,
                     M2   TYPE  ZLT_mita-M2,
                 END  OF  ty_DAT.
    DATA: it_dat        TYPE STANDARD TABLE OF ty_dat with header line,
              wa_dat      TYPE   ty_dat.
    PARAMETERS: p_mitar    TYPE  Zlt_Mita-M2.
    SELECT           M1
                           M2
            FROM     ZLt_mita
            INTO       TABLE it_dat
            Where     M2 = p_mitar.
    Loop at it_dat into wa_dat.
       WRITE:/2 wa_dat-M1,
                  10 wa_dat-M2.
    ENDLOOP.
    2) When I try to pull data from Dbase table by taking M1 as parameter.
         This code is NOT succcessful and I am NOT able to populate data in internal table it_dat.
    TYPES: Begin Of ty_DAT,
                     M1   TYPE  Zlt_mita-M1,
                     M2   TYPE  ZLT_mita-M2,
                 END  OF  ty_DAT.
    DATA: it_dat        TYPE STANDARD TABLE OF ty_dat with header line,
               wa_dat      TYPE   ty_dat.
    PARAMETERS:    P_Mita    TYPE   ZLT_Mita-M1.
    SELECT           M1
                           M2
            FROM     ZLt_mita
            INTO       TABLE it_dat
            Where     M1 = P_Mita.
    Loop at it_dat into wa_dat.
       WRITE:/2 wa_dat-M1,
                 10 wa_dat-M2.
    ENDLOOP.
    Why is this happening when both M1 and M2 are Type Character fields.
    Looking forward for your replies.
    Regards
    Chandan Kumar

    Hi Chandan ,
    Database fetch is case sensitive ,So u need to give exact format in where condition.
    Make your parameter and database in same case so that you need not worry about case sensitivity .
    Check the lowecase check box in the domain .
    Then declare your parameter 
    PARAMETERS:
    P_Mita
    TYPE   ZLT_Mita-M1 LOWER CASE . 
    You can do the vice versa also by unchecking lowercase and giving Upper case instead of lower in parameter declartion .
    Regards ,
    Juneed Manha

  • How to use dynamic select query which queries from 3 different table.

    Hi All,
    I am new to Toplink, i would like to use a named query to select some of the columns from 3 different tables with dynamic where clause.
    I have used the following lines. Please tell me how to get code for the dynamic where clause.
    First try :
    Vector objPersons = (Vector)session.executeQuery("findPersonByGlobalID",Person.class,vQueryArguments);
    The above method is not returning the vector or collection.
    Second Try:
    ReadAllQuery query = new ReadAllQuery(Person.class);
    query.useCollectionClass(LinkedList.class);
    LinkedList person = (LinkedList) session.executeQuery(query);
    The second try is returning the collection but, this fetches all the record from the table.
    1. How to query for range of records?
    2. How to query from multiple tables for some range. How to use dynamic range values ?
    Please reply with your answers or some pointers would help.
    Thanks and Regards,
    Vijay.B

    Hi,
    Did you try using a SQLCall ? It might be able to satisfy you requirements .. :-
    Employee employee = (Employee) session.executeSelectingCall(
        new SQLCall("SELECT * FROM EMPLOYEE WHERE EMP_ID = 44")
    );You can get more information here :-
    http://www.oracle.com/technology/products/ias/toplink/doc/1013/MAIN/_html/qrybas004.htm
    Regards,
    Sandeep

Maybe you are looking for

  • Use of Commodity Code/Import Code Number

    Anybody using Commodity Code/Import Code Number in MM02 under the Foreign trade tab? Can you tell me what you are doing with this field? Thanks, Joe.

  • Data Loader - Only imports first record; remaining records fail

    I'm trying to use Data Loader to import a group of opportunities. Everytime I run the Data Loader it only imports the first record. All the other records fail with the message "An unexpected error occurred during the import of the following row: 'Ext

  • Emails not being recieved

    Hi, Please can someone help because this is driving me loopy! My BB isn't receiving emails but will let me send them just fine. I have tried out the host routing table way as read from another post but this hasn't worked. Please if anyone can help pl

  • When will Apple provide iPhone to all?

    When will Apple realize that the iPhone is the only phone for many people and therefore will increase sales to the max by providing iPhone to all customers via all service providers?

  • How to make a select list editable or searchable like the combobox

    Does anybody know, How to make a select list editable or searchable like the combobox? Do we need a plugin here, where I can get it.