Multiple DB queries to different tables are botching my page

Hello everybody,
This one's going to be a bit difficult to explain clearly, but I will do my best.
ADDED: After posting this thread, I have been browsing a lot of forums and tutorials. I see a lot of praise for JOIN but I see nothing of lookup tables, as David Powers was so kind to show us in PHP Solutions. I like the lookup table and it works for me rather well. I'm curious as to why it gets no play yet the JOIN command does? Further, many uses of JOIN that I am seeing appear, to me as a novice, to be solveable with WHERE and AND as opposed to JOIN. Gotta go now, my temples are splitting. Cheers!
Okay, I have a TOC (table of contents) page I am working on as part of my online photo gallery. When you land on the preceding page for category selection, you have three choices. Picking one sends you to the TOC and with the associated query string value, the TOC page opens with the appropriate data.
I have eleven separate queries that collect the information to stock the page. It looks beautiful when it works, and all of this works when there is only ONE gallery presented. It's when I get into presenting many per page that the queries collide. And yes, all of the tables I will mention next are part of the main DB.
Please note, the 'names' of the tables shown are casual references, not the actual table names.
From my 'galleries' table, I pull these records using the first three queries:
1. Total number of galleries that match the value of the query string
2. Retrieving a subset of data (in this case, x-amount of galleries to display per page)
3. Gallery names and descriptions
The above three queries work in harmony although I can not get the number of galleries that I want displayed on a page (if I want 3 to show up and there are 4 total, I get all 4). I do, however, get all of the appropriate data for the above and it looks fantastic.
Next, when I add any or all of these queries, the aabove-mentioned info gets botched.
From my 'galleries' and 'photos' tables, I pull these records:
4. First representative thumbnail per gallery
5. Second representative thumbnail per gallery (I use two, it makes the layout look nice. These are just to give you an idea of what you'll see if you select this gallery)
6. The total number of photos in any photoset belonging to the category of galleries being displayed.
From my 'model names', 'model lookup' and 'galleries' tables I pull these records:
7. Model name/names associated with any specific gallery
From my 'subject names', 'subject lookup, and 'galleries' tables I pull these records
8. The subject, which is an initial set of 'categories' (used in the page header, title and some links).
'category names', 'category lookup, and 'galleries' tables I pull these records:
9. Category name (used in the page header and title)
'photographer names,  'photographer lookup' and 'galleries' tables I pull these records:
10. Photographer name associated with any specific gallery
'mua (make-up artist) names,  'mua lookup' and 'galleries' tables I  pull these records:
11. Make-up artist name associated with any specific gallery
Now, if at this point, you are wanting to smack me over the head asking, 'Why are you doing it this way?' please note that I am extremely new to this and am open to suggestions that help to streamline things. Still, these eleven separate queries are all dealing with specific data types and unless there's some magical way to combine these all into one query (which to date my research has shown to not exist), I'm stuck with eleven queries.
Out of frustration, I have tried adding $result->free_result(); after my queries, but they bomb the page when I go to test it locally. What is the proper time to use this command, and what is the proper syntax?
Also, is it necessary to have more than one connection ($conn = dbConnect('query');) per page? Should I have one preceding every query? Would just one for all eleven queries do the job? I have to say, for the page that worked completely only displaying one gallery and all of this lovely data, one connection did the job. Is this bad practice?
I apologize if this is the least bit confusing. My descriptive prowess is not at all what it usually is due to woeking on this project dya in and day out...me brain is fried. However, I am making progress, but now, this is my tallest hurdle yet.
Thanks to any and all of you who can help!
Sincerely,
wordman

>I'm curious as to why it gets no play yet the JOIN command does?
First of all, JOIN is not a command. It's a statement. It's a way of combining table columns using the JOIN "keyword" within the FROM clause.
>Further, many uses of JOIN that I am seeing appear, to me as a
>novice,  to be solveable with WHERE and AND as opposed to JOIN.
You can either use the JOIN keyword, or join tables within the WHERE clause. Both yield the same results. In the past, the only option was to use the WHERE clause, but things like outer join syntax varied among different DBMS's. Later versions of the ANSI standard introduced the JOIN keyword which standardized join syntax. But you can use whichever you are more comfortable with as most query optimizers will give the same results.
>Still, these eleven separate queries are all dealing with specific data
>types and unless there's some magical way to combine these all into
>one  query (which to date my research has shown to not exist), I'm stuck
>with  eleven queries.
If you are populating a page with data, then I assume that the data on the page is related in some way. If the data is related, then there must be a way to combine the queries. It may not make sense to combine ALL of them, but I guarantee that running 11 queries for a page is the wrong approach. Looking at your examples, it seems like this is achieveable.
I would really urge you to step back and learn some more SQL. JOINS are not an advanced topic. There is plenty of good material on the web for learning SQL, or you can find some great books if that's more your style.

Similar Messages

  • Need Help!!! Trying to sum 3 different table subtotals on one page

    I followed an example of how to create an expandable table (purchase order style with drop-down menu) and I was not able to conitune the form on pages 2 through 3.  So I duplicated the first table on the pages 2 and 3; and renamed the number index to correspond to the first table.  However, I need the subtotal of each page to be added in the Grand Total on Page 4 but thus far I have not found a formula that works.  I have changed the binding name to reflect each different formula but no luck yet.  I am willing to attach the file so that anyone can see what I have done.  Thanks for your help!

    You can upload your form to https://workspaces.acrobat.com/app.html and share a link for us to download your file.

  • Loading Multiple excel sheets in to different tables in a DB

    Hi All,
    I have problem in loading multiple excel sheets data in to according to that excelsheets tables in a DB.
    All the excel sheets are in a folder,from that folder i have to  acces all excel sheets.
    For this i am unsing script task and one dataflow task.
    But the error is coming in script task i am not able to put the path in the script..
    Is this the correct way to do like this? Or any other way?
    Can u please tell me the solution for this..Thanks in advance who are responding to this mail...
    Maruthi..

    Hi Vipin,
    Here you go with this requirement
    How to Load Multiple Sheets From Multiple Excel Files to Different Tables in SSIS Package?
    ttps://www.youtube.com/watch?v=1WXKpkwjhX8&feature=youtu.be
    I have other videos as well where you want to load all the sheets from file/s to same table 
    https://www.youtube.com/watch?v=F3sYO-S9icc&feature=youtu.be
    Check out the last links on below links all related to Excel
    http://sqlage.blogspot.com/search/label/SSIS%20Videos
    How to Create Excel file with Date-time on Each Package Execution in SSIS Package?
    How to Load Multiple Sheets to a SQL Server Table in SSIS Package?
    How to Load Data Excel File to SQL Server Table and Solve Data Conversion Issues?
    How to Load Multiple Sheets From Multiple Excel Files to Different Tables in SSIS Package?
    How to Load Data to Pre-Formatted Excel Sheet (Excel Report) in SSIS Package?
    All the best!
    http://sqlage.blogspot.com/

  • 2 manually created tabular form on the same page based on 2 different table

    Hi, I followed the how to document on manually creating tabular form, including one extra row.
    The first form I created works fine, but when I attempt to create the second tabular form based on a different table on the same page, I get the following error message when I try to create the query:
    ORA-04045: errors during recompilation/revalidation of PUBLIC.X ORA-00980: synonym translation is no longer valid
    The logic behind both tabular forms I am using is the same, except that for the second query, I use 100 instead of 1, 300 instead of 3, etc:
    select htmldb_item.hidden(1,empno) empno,
    ename,
    htmldb_item.select_list_from_query(3,job,'select distinct job, job from emp') job,
    htmldb_item.popupkey_from_query(4,mgr,'select ename, empno from emp',10) mgr,
    wwv_flow_item.date_popup(6,null,hiredate) hiredate,
    htmldb_item.text(7,sal,10) sal,
    htmldb_item.text(8,comm,10) comm,
    htmldb_item.select_list_from_query(9,deptno,'select dname, deptno from dept') deptno
    from emp
    Can anybody help?
    Thanks a lot

    Hi,
    If by "100 instead of 1" you mean the column numbers, then this won't work as you can only have a maximum of 50.
    Andy

  • Two different TOC styles in one Pages document?

    I'm a new Pages 2.0.2 user with a large document with two different tables of contents 20 pages apart. I'm trying to format them differently using different TOC styles but when I change one's style the other one changes as well. Anything I do format-wise to one goes over to the other as well. I'm hoping this is just something I have yet to learn about the product. Any thoughts?
    iMac G5   Mac OS X (10.3.9)   1GB Memory

    Hi
    Someone else might know but this doesn't look good, taken from Pages Help:
    "Changing the appearance of text in a table of contents
    You can change the appearance of text in a table of contents and also add a leader line between a TOC heading and its associated page number.
    To change the appearance of text in a table of contents:
    Select the TOC heading you want to change. When you select a TOC heading, all the entries of the same heading type are automatically selected; headings cannot be individually selected.
    Click View in the toolbar, and then choose Show Styles Drawer.
    The Styles drawer displays a list of table of contents (TOC) styles. The TOC style that corresponds to the selected entry type is also selected.
    Do one or more of the following:
    To change the appearance of text, change it as you would format any paragraph text. For example, choose Format > Font or use the Text Inspector to make edits.
    To create leader lines from a TOC heading to its associated page number, click Inspector in the toolbar, click the Text Inspector button, and then click Tabs. Click the value for the TOC in the Tab Stops list, and then choose a line style from the Leader pop-up menu."

  • Two forms that update differrent tables on the same page?

    I tried to add two forms that update different tables on to one page.
    Problem is when I do that the forms gives me an error saying the field does not exist. It's like it is trying to update one table with the other tables fields.
    As an example Say I have one forms that is for people table and another one that is the Jobs table.
    When I go to update the people table, it sends the data for the jobs fields too I get an error like the field job description does not exist.
    I have two different forms for these and everything.
    I would hope it is possible to have two forms that update different tables on the same page.

    I was trying the exact same thing, but i managed to work round it by setting the steps to hide one region, so the user would enter the form see one region submit the region then direct back to the same page with the different region visible and the original hidden.
    I don't know if this would be acceptable for you...

  • Multiple Queries on Same/Different Table?

    Hello all,
    I have started to learn how to integrate java with databases using JDBC. However I have a question that would make my life much easier. From what I've learned everytime I want to do a query, I have to create a new statement and new result set to perform the query on same/different tables. This seems rather redundant and inefficient. Is there a way to go around this? Suppose I wanted to SELECT * FROM A and then perform SELECT name FROM A WHERE <some condition> and then output both of them. Is there any way I can just build upon my old result set? Or must I create a whole new result set and connected statement everytime?
    Edited by: dnguyen1022 on Oct 9, 2009 11:16 PM

    dnguyen1022 wrote:
    Hello all,
    I have started to learn how to integrate java with databases using JDBC. However I have a question that would make my life much easier. From what I've learned everytime I want to do a query, I have to create a new statement and new result set to perform the query on same/different tables. That isn't entirely true but normally that is what you do.
    This seems rather redundant and inefficient. Compared to what? The roundtrip to the database and the work that the database does to get the data? Then no it is very efficient.
    Is there a way to go around this? Suppose I wanted to SELECT * FROM A and then perform SELECT name FROM A WHERE <some condition> and then output both of them. A JDBC query can consist of more than one result set.
    Note that if if you have real performance problem (measured production load) then alternative designs are much more likely to lead to substantial savings versus fiddling with actual queries. If you haven't actually profile the app then note that focusing on the architecture/design rather than implementation of any application will lead to far more performance benefits.

  • How to use a USER_DATASTORE to index multiple columns in different tables

    I would appreciate if somebody can give an example or point to links with examples on how to use USER_DATASTORE on multiple columns in different tables. THe Oracle Text documentation only shows multiple columns in the same table.
    Thanks in advance.

    I am not sure why your getting the wrong results but you should seriously reconsider the approach your are taking. Using functions like this is very ineffecient and should be avoided at all cost.

  • How to Query Multiple Fields from different Tables using Toplink Expression

    Hi,
    I am trying to prepare an Oracle Toplink Expression to qurey the multiple columns of different tables. the query as following. Please can anyone help?
    SELECT CYCLE.CYCLE_ID,
    CYCLE.ASPCUSTOMER_ID,
    CYCLE.FACILITYHEADER_ID,
    CYCLE.ADDUSER,
    ASP.FIRSTNAME || ' ' || ASP.LASTNAME ADDUSERNAME,
    CYCLE.ADDDATE,
    CYCLE.LASTUPDATEUSER,
    ASP.FIRSTNAME || ' ' || ASP.LASTNAME LASTUPDATEUSERNAME,
    CYCLE.LASTUPDATEDATE,
    CYCLE.CYCLENAME,
    CYCLE.CYCLENUMBER,
    CYCLE.DESCRIPTION
    FROM CYCLE,ASPUSER ASP
    WHERE CYCLE.ADDUSER = ASP.ASPUSER_ID
    and then i want to send that expression to readAllObjects method as a parameter
    Expression exp = (..............this is the required qurey expression...................)
    Vector employees = session.readAllObjects(getClass(), exp);
    thanks,

    You havent given any information on the mapping between Cycle and Asp. I presume there is a one to one mapping between them. Also it appears there is no "WHERE" clause to limit the number of cycles being retrieved. If that is the case then I presume you want to load all cycles in the system.
    Thats just a clientSession.readAllObjects(Cycle.class). If you have indirection turned on the Asp should get loaded when you do a cycle.getAsp().
    I presume that SQL you posted loads all the columns of CYCLE and ASP. If you are interested in a subset of CYCLE or ASP then you should do a ReportQuery or partial object read.
    Hi,
    I am trying to prepare an Oracle Toplink Expression
    to qurey the multiple columns of different tables.
    the query as following. Please can anyone help?
    SELECT CYCLE.CYCLE_ID,
    CYCLE.ASPCUSTOMER_ID,
    CYCLE.FACILITYHEADER_ID,
    CYCLE.ADDUSER,
    ASP.FIRSTNAME || ' ' || ASP.LASTNAME ADDUSERNAME,
    CYCLE.ADDDATE,
    CYCLE.LASTUPDATEUSER,
    ASP.FIRSTNAME || ' ' || ASP.LASTNAME
    LASTUPDATEUSERNAME,
    CYCLE.LASTUPDATEDATE,
    CYCLE.CYCLENAME,
    CYCLE.CYCLENUMBER,
    CYCLE.DESCRIPTION
    FROM CYCLE,ASPUSER ASP
    WHERE CYCLE.ADDUSER = ASP.ASPUSER_ID
    and then i want to send that expression to
    readAllObjects method as a parameter
    Expression exp = (..............this is the required
    qurey expression...................)
    Vector employees = session.readAllObjects(getClass(),
    exp);
    thanks,

  • How to update multiple columns from different tables using cursor.

    Hi,
    i have two tables test1 and test2. i want to udpate the column(DEPT_DSCR) of both the tables TEST1 and TEST2 using select for update and current of...using cursor.
    I have a code written as follows :
    DECLARE
    v_mydept1 TEST1.DEPT_CD%TYPE;
    v_mydept2 TEST2.DEPT_CD%TYPE;
    CURSOR C1 IS SELECT TEST1.DEPT_CD,TEST2.DEPT_CD FROM TEST1,TEST2 WHERE TEST1.DEPT_CD = TEST2.DEPT_CD AND TEST1.DEPT_CD = 'AA' FOR UPDATE OF TEST1.DEPT_DSCR,TEST2.DEPT_DSCR;
    BEGIN
    OPEN C1;
         LOOP
              FETCH C1 INTO v_mydept1,v_mydept2;
              EXIT WHEN C1%NOTFOUND;
              UPDATE TEST2 SET DEPT_DSCR = 'PLSQL1' WHERE CURRENT OF C1;
              UPDATE TEST2 SET DEPT_DSCR = 'PLSQL2' WHERE CURRENT OF C1;
         END LOOP;
         COMMIT;
    END;
    The above code when run says that it runs successfully. But it does not updates the desired columns[DEPT_DSCR].
    It only works when we want to update single or multiple columns of same table...i.e. by providing these columns after "FOR UPDATE OF"
    I am not sure what is the exact problem when we want to update multiple columns of different tables.
    Can anyone help me on this ?

    oops my mistake.....typo mistake...it should have been as follows --
    UPDATE TEST1 SET DEPT_DSCR = 'PLSQL1' WHERE CURRENT OF C1;
    UPDATE TEST2 SET DEPT_DSCR = 'PLSQL2' WHERE CURRENT OF C1;
    Now here is the upated PL/SQL code where we are trying to update columns of different tables --
    DECLARE
    v_mydept1 TEST1.DEPT_CD%TYPE;
    v_mydept2 TEST2.DEPT_CD%TYPE;
    CURSOR C1 IS SELECT TEST1.DEPT_CD,TEST2.DEPT_CD FROM TEST1,TEST2 WHERE TEST1.DEPT_CD = TEST2.DEPT_CD AND TEST1.DEPT_CD = 'AA' FOR UPDATE OF TEST1.DEPT_DSCR,TEST2.DEPT_DSCR;
    BEGIN
    OPEN C1;
    LOOP
    FETCH C1 INTO v_mydept1,v_mydept2;
    EXIT WHEN C1%NOTFOUND;
    UPDATE TEST1 SET DEPT_DSCR = 'PLSQL1' WHERE CURRENT OF C1;
    UPDATE TEST2 SET DEPT_DSCR = 'PLSQL2' WHERE CURRENT OF C1;
    END LOOP;
    COMMIT;
    END;
    Please let us know why it is not updating by using using CURRENT OF

  • 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

  • Proper use of one table in different business areas

    Hi
    We will be using certain DB tables in several business areas and we are more than one person to define them.
    If a table is loaded from the database for each of the business areas it will be numbered 'table 1, 2...' which does't seem very desirable. Also I'd rather define hiearchies only once and for all.
    If a table is loaded only once and used for all the business areas all the joins which are necessary in the different business areas are shown. This will be confusing. If one of us considers a certain join unnecessary he might accidentially delete the wrong one belonging to a different business area.
    Exporting the business areas including the joins regularly is probably not a great help if afterwards new joins for other business areas were added.(?)
    Am I misunderstanding the concept of Discoverer?
    How do you handle such a situation?
    Advice appreciated
    Franziska

    Hi Michael, et al,
    I'm just planning my EUL and your comments in the last post seem relevant.
    My general plan is as follows:
    (1) Create a BaseMaster BA which is used to bring and tables/views from the database into disco. The folders in here will be created with "New Folder from database" and be fairly straightforward, with only very simple calculations and no aggregations in calculations. The joins will echo the joins in the underlying database. This is not shared with Users.
    (2) Create a CustomMaster BA which contains Custom Folders which consist of various SQL views of the database. The SQL in these may use have some more complex calculations and these calculations may include aggregation. This will not be shared with users.
    (3) Create a CentralMaster BA which contains Complex Folders which are assembled from items from the BaseMaster BA and the CustomMaster BA. These folders may include more complex calculations and the calculations may include aggregated items.
    (4) Create a number of User BA's. Using Manage Folders, share the relevant Folders from the Central Master.
    I've got a few questions relating to this.
    (a) Custom Folders based on Folders
    It would seem nice to me if it were possible to create Custom Folders which were based on other Folders, rather than Database Views. Then, even if you need a view and a complex transformation of that view in your business area, you still only have one place where the EUL brings that view into disco. My understanding is that this is not possible. Am I right? I suppose there could be an argument that complex transformations should be pushed back to the DBA but it seems reasonable to me that sometimes this sort of thing could be within the remit of the disco admin?
    (b) SQL Efficiency
    Am I right in thinking that generally a complex folder is usually not much less efficient than using a base folder because the SQL interpreter ends up optimising the SQL?
    And a last question which has turned out rather complex - by all means ignore it if you like - it's me getting to grips with the process.
    (c) Nested Complex Folders
    I presume that if a transformation is needed which would in a normal database environment would need a mainquery and a subquery, then this could be done in a
    number of ways (adhering to the above methodology) by:
    (i) Get the DBA to write a view which does both mainquery and subquery and then bring into the BaseMaster and then straight into the CentralMaster folder.
    (ii) Get the DBA to write the subquery, bring this into the BaseMaster and then implement the mainquery in the CentralMaster.
    (iii) Create a Folder in CustomMaster which implements both mainquery and subquery and then bring this into the CentralMaster folder.
    (iv) Create a Folder in the CustomMaster which implements just the subquery and then implement the main query in the Central Master.
    If you've got this far - thankyou for baring with me.
    Perhaps there's something written about this sort of thing or maybe it's just a matter of practice!
    Any thoughts on all this would be much appreciated.
    Kind regards
    Suhada

  • BEx Broadcaster - Using a Workbook with multiple queries on different tabs

    Hi,
    I was wondering if any has used Bex Broadcaster to broadcast a workbook that contains multiple queries on different tabs in the workbook.  I believe someone has mentioned that this was an issue in the past and I was wondering if this now a possibility with Bex Broadcaster
    If you were able to do this successfully, please let me know.
    Thanks

    Hello
    Of course it is possible.
    But, if you want to broadcast a workbook, you have to use a Precalculation Server.
    Without precalculation server, workbooks cannot be precalculated and broadcasted.
    More details, please check the note below:
    1461398          BW 7.X(7.20) Precalculation - General Info. & Limitations                              
    Best regards,
    Edward John

  • Multiple keyfigure from different planning area based on attribute value

    Multiple keyfigure from different planning area based on the attribute value of Cost element charac.
    I need to obtain the value of the attribute in a fox function. Let me explain it further.
    Background :
    Planning area -
    Charac----
    KF
    area1 -
    Payscale group--- Amount
    Cost element------AmountVR
    area2--Payscalegroup----KF1
    KF2
    KF3
    Cost Element has an attribute "Type"
    Value for attribute "Type" = 1,2,3
    Based on the value of the attribute, the corresponding KF needs to be multiplied.
    Logic :
    If type = 1.
    AmountVR = Amount * KF1.
    elseif type = 2.
    AmountVR = Amount * KF2.
    elseif type = 3.
    AmountVR = Amount * KF3.
    endif.
    The problem I'm facing is that I'm not able to read the data of attribute "Type". None of the below statement retrieve the value of the "Type".
    TYPE = ATRV(Attribute,COSTELEMENT,CO_AREA)
    or
    TYPE = ATRV(Attribute,COSTELEMENT)
    Could you please help me in reading from a time dependent compounding InfoObject?
    Regards,
    Raghu

    Hi..
    Thanx Bindu..
    I have actual data for Month days..if i am craeting in same layout it is too large.
    that's why i am creating two layouts.
    below example for better undersatnding.
    Actual:
    D1 :D2: D3  :D4 : D5  :D6 : D7   :  FULLACT (sume of C(1)  sum of d1 to d7))
    10  :8  :12 :  10 : 14   : 6  : 10    :  70     
    Plan:
    D1EST : D2EST: D3EST :D4EST :D5EST: D6EST: D7EST:  FULLEST (sum of d1 to d7)
    10         :10        :  10      :  10      :10       :    10    :     10  :         70
    How can i read FULLACT value and that value i have to distribute  equally in planing layout and always FULLEST is equal to FULLACT.if not equal i have to throug error message hoe can i setup if you have sample code can you send it to me.
    what is your idea....
    Edited by: Eyda rose on Jun 4, 2008 4:59 PM

  • How to display multiple data from different table in one table? please help

    Hi
    I got sun java studio creator 2(the separate installation not the one in the net beans)....
    My question is about displaying data that have been taken from the database.... I know how to display data in a table(just click on the table "bind data" )... but my question is that:
    when i want to use a sql statement that taken the data from different table...
    how can i display that data in the table(that will be shown in the web) ??? when i click bind data on the table i can only select one table i can't select more than one....
    Note:
    1) i'm using the rowset for displaying the data in the table, since the sql statement is depending on a condition(i.e. select a from b where c= ? )...
    2) i mean by different table is that( i.e. select a from table1,table2 )..
    thanks in advance...

    Hi,
    937440 wrote:
    Hi every one, this is my first post in this portal. Welcome to the forum!
    Be sure to read the forum FAQ {message:id=9360002}
    I want display the details of emp table.. for that I am using this SQL statement.
    select * from emp where mgr=nvl(:mgr,mgr);
    when I give the input as 7698 it is displaying the corresponding records... and also when I won't give any input then it is displaying all the records except the mgr with null values.
    1)I want to display all the records when I won't give any input including nulls
    2)I want to display all the records who's mgr is null
    Is there any way to incorporate to include all these in a single query..It's a little unclear what you're asking.
    The following query always includes rows where mgr is NULL, and when the bind variable :mgr is NULL, it displays all rows:
    SELECT  *
    FROM     emp
    WHERE     LNNVL (mgr != :mgr)
    ;That is, when :mgr = 7698, it displays 6 rows, and when :mgr is NULL it displays 14 rows (assuming you're using the Oracle-supplied scott.emp table).
    The following query includes rows where mgr is NULL only when the bind variable :mgr is NULL, in which case it displays all rows:
    SELECT     *
    FROM     emp
    WHERE     :mgr     = mgr
    OR       :mgr       IS NULL
    ;When :mgr = 7698, this displays 5 rows, and when :mgr is NULL it displays 14 rows.
    The following query includes rows where mgr is NULL only when the bind variab;e :mgr is NULL, in which case it displays only the rows where mgr is NULL. That is, it treats NULL as a value:
    SELECT     *
    FROM     emp
    WHERE     DECODE ( mgr
                , :mgr, 'OK'
                )     = 'OK'
    ;When :mgr = 7698, this displays 5 rows, and when :mgr is NULL, it displays 1 row.

Maybe you are looking for