User selection to return filtered record set

Hi,
I want to create a JSP which allows a user to enter search criteria for several columns of a table. I will use the entered values to set the sql where clause and produce the filtered record set. (eg the user enters a particular customer code and status code in order to see a list of orders placed by that customer which have the selected status code.)
The problem I have is this: I want the input fields for the selection criteria to be combo boxes populated with values from the database.
What is the best way to do this?

Hi,
I want to create a JSP which allows a user to enter search criteria for several columns of a table. I will use the entered values to set the sql where clause and produce the filtered record set. (eg the user enters a particular customer code and status code in order to see a list of orders placed by that customer which have the selected status code.)
The problem I have is this: I want the input fields for the selection criteria to be combo boxes populated with values from the database.
What is the best way to do this?

Similar Messages

  • Return a record set from a procedure

    I am building an application for my company.
    Before oracle I had used MS SQL Server for a long time.
    I build a procedure as following
    CREATE OR REPLACE PROCEDURE YBP.ReturnSet
    -- Return a record set from a procedure
    IS
    BEGIN
    SELECT * FROM fdbase;
    END;
    But the complier show me a error message:
    <font color="#0000FF">PLS-00428     an INTO clause is expected in this SELECT statement</font>
    I read the error details
    <font color="#0000FF">"In PL/SQL, only a subquery is written without an INTO clause."</font>
    But I know that this procedure can run well in <font color="#0000FF">MS SQL Server .</font>
    How I can do this thing in Oracle
    Any help will be appreciate!

    I have a stored proc that is defined as
    CREATE or REPLACE
    PROCEDURE ABC
    (linkid IN CHAR,
    Year_in IN DATE,
    Method_in IN CHAR,
    Date_out OUT DATE,
    average_out OUT NUMBER)
    is
    begin
    .. Date_out := ...;
    average_out := ...;
    end;
    another partially completed stored proc that returns a ref
    cursor defined as follows:
    create or replace package zzz
    as
    type cursorType is ref cursor;
    end;
    create or replace function test return zzz.cursortype
    as
    date_OUT date;
    Average_OUT number;
    l_cursor zzz.cursorType;
    CURSOR temp_cur is
    SELECT l.linkid, L.routenumber, ABC(l.linkid,
    to_date('01/01/2000', 'mm/dd/yyyy'),
    '2',
    date_OUT,
    average_OUT)
    FROM LINK l
    WHERE l.LINKID <= '010999';
    begin
    open temp_cur;
    end;
    inside test (which I need help completing), how can I refer to
    the date_out and the average_out params returned by ABC() so
    that these values are in turn passed to the cursortype defined
    in package zzz?
    Thanks in advance.

  • Returning Multiple Record sets to VB.

    Is it possible using an Oracle 7 Driver connecting to a Oracle 9i database to return multiple record sets to screens written in VB? this is all a new area for me and the people I've spoken to so far seem to think it isn't possible - I refuse to believe this - someone must have done this before?!?!? Can someone confirm either way before I go down this path!!!!
    Cheers

    Sounds like you need a join statement in your SQL, is the
    category and field info in different tables, then a join would be
    perfect, also what language are you using. I know another way in
    php you could use a while loop with another RS inside that gets the
    proper field info for each category.
    check out this:
    http://www.w3schools.com/sql/sql_join.asp

  • Show Mulitiple selection drop down from record set highlighted.

    Anyone know how I can show the multiple selection from my record set on my drop down list?
    What I've done is allowed users to select multiple items on from the dropdown list but now want to be able to display it from the record set back into the drop down list.
    Any help would be great!!
    thanks
    [Moved to the Dreamweaver Application Development forum by moderator]

    Check this:
    Filtering using the current() function
    This post is my own opinion and does not necessarily reflect the opinion or view of Slalom.

  • Can select statement return 'No Record found' for each of invalid inputs.

    Let say when you select a invalid booking number, oracle will
    return nothing, but do u know how to make oracle return a record
    saying it's invalid?
    Example, the following sql normally return 3 records cause
    only 3 numbers are valid, is there anyway to make it return
    4 records and indicate those invalid ones are invalid somehow.
    select booking_service, BOOKING_NO from tb_booking where booking_no in ('valid1','INVALID', 'valid2', 'valid3')

    Along the same lines you could use object types to achieve the same result. This would remove the need for a temporary table, and also allow you to create the list of ids to check with PL/SQL without i/o. As an example
    CREATE TYPE booking_id_typ IS OBJECT (id NUMBER);
    CREATE TYPE booking_id_list_typ IS TABLE OF booking_id_typ;
    CREATE TABLE bookings (booking_id booking_id_typ);
    (you could have booking_id as type NUMBER, but for consistency with subsequent SQL I've used booking_id_typ)
    INSERT INTO bookings VALUES (booking_id_typ(10));
    INSERT INTO bookings VALUES (booking_id_typ(20));
    INSERT INTO bookings VALUES (booking_id_typ(40));
    INSERT INTO bookings VALUES (booking_id_typ(50));
    The following SQL statement creates a collection on the fly, rather than using an IN clause.
    SELECT i.id booking_id, DECODE(b.booking_id.id, NULL, 'Invalid', 'Ok') status
    FROM bookings b,
    SELECT id
    FROM TABLE(booking_id_list_typ(booking_id_typ(10), booking_id_typ(20), booking_id_typ(30), booking_id_typ(40)))
    ) i
    WHERE i.id = b.booking_id.id (+)
    BOOKING_ID STATUS
    10 Ok
    20 Ok
    30 Invalid
    40 Ok
    This SQL statement works in 9i. I get the following error in 8i, but you might be able to CAST the TABLE to booking_id_list_typ, or depending on your application, create a PL/SQL variable of type booking_id_list_typ and CAST that instead.
    ERROR at line 5:
    ORA-22905: cannot access rows from a non-nested table item

  • Parameter in select to returns all records.

    Post Author: ComputerMike
    CA Forum: Crystal Reports
    Hi,
    I have a "project" parameter I use in my select formula to return records based the project field.  I would like to pass a value like "All" or "*" and have all reords returned, to see the records for all the projects.  If I pass in "3" I would just get records for project 3.  "All" would give me all the projects.
    Thanks,
    Mike

    Post Author: GraemeG
    CA Forum: Crystal Reports
    Modify your selection formula to something like:
    (if {?project} <> "ALL" then   {table.project} = {?project}else   1 = 1)
    You have to specify an 'else' and the above is a cheat that makes sure everything is selected if 'ALL'  is entered. A suggestion - make 'ALL' your parameter default.

  • URGENT Select Query Returning No Records take same time as that of insert

    Hello Everrybody,
    I am facing a wierd problem...
    I have table with 15 fields and I am selecting a record with some condition...
    for e.g
    select field1,field2,field3....... from tablea where field1=123
    Now I have index on field1
    When I do SQL Trace it show me time taken as
    00:00:00:60 in oracle 817 SQL PLUS
    and using
    oracle 92 sql plus it show as
    00:00:00:01 in oracle 817 SQL PLUS
    Now Query is what does this 60 denotes milliseconds or what in oracle 92 and in oracle 817 sql plus.....
    Also this query does not return any rows...
    When I run the SP that insert records in same table...That sp take about same time as that of select returning no rows......
    Why is ORACLE Taking so much time for that select ????
    Please help.....

    8i measures timings in 100th of a second but I believe that 9i measures stuff in 1000th of a second. However, from your output it looks like SQL*Plus trace is rounding up to the nearest centisecond.
    Time is a very poor way of judging performance when you're talking less than a second per operation. You'd be better off looking at CPU usage and IO activity.
    Anyway, here are some questions for you to research:
    (1) Is field1 a unique index?
    (2) How many rows does this table hold?
    (3) How fresh are the statistics on the table and the index?
    (4) What's the explain plan? What's the TKPROF output?
    (5) Are all of the above the same on both databases?
    Cheers, APC

  • Returning filtered records based on login password

    Hi,
    I'm using MySql / PHP / DW
    I have a 'login.php' page which has two fields USERNAME & PASSWORD, and a 'jobs.php' page which displays a list of Client's jobs.
    I need Client A to log in and only see Client A's jobs and so on for my various clients...
    I have two tables, USER and JOBS.
    USER TABLE
    client_id (primary key)
    username
    password
    access_level
    JOBS TABLE
    job_id (primary key)
    client_id
    client
    site
    install_date
    I need 'jobs.php' to display Client A's jobs based on the username and / or password he has entered.
    Do I have to create a query in MySql or can I achieve this within DW in recordsets or something? I'm very confused!
    Thanks

    I had to do something very similar using .asp and MSaccess many years ago, back then I had to create a query in Access which merged the two tables together and then I created a recordset from it in Dreamweaver. Can I replicate this using MySql / Phpmyadmin and have the query show up in Dreamweaver so I can create a recordset from it?
    Back to present day...How do I retrieve the id of a record?
    On the client records page I have entered this data below - can you tell me if this is correct? When I test it records are displayed but when I preview in browser the records page comes back empty.
    Simple view:
    Advanced view:

  • Using java beans to return a record set

    Hello,
    I fairly new to JSP and what I'm trying to do is use Beans to connect to a database and then display the result on the JSP page. Can someone please post an example of how I would do this from a JSP page. I already have my JDBC code set up.
    Thanks

    Thanks for the feedback M
    I have added the JSTL 1.1 library and used the Foreach components and data source components which now totally eliminate the need for beans altogether. :P
    <c:forEach var="row" items="${deejays.rows}">
    <tr onmouseover="this.bgColor='gold';"
    onmouseout="this.bgColor='#FFFFFF';">
    <c:forEach var="column" items="${row}">
    <td>
    <c:out value="${column.value}"/>
    </td>
    </c:forEach>
    <td width="24%" align="center">
    <input type="image" src="7af5.jpg" name="test" value="test"/>
    </td>
    <td width="15%">
    <input type="radio" name="book1"/>
    </td>
    </tr>
    </c:forEach>
    </table><p align="left">
    How and where do i add the beans in here now???

  • Record set

    Hi
    I come from VB background and very new to java.
    Is it possible to return a record set from call method like in VB?
    AP

    Yes.

  • Dynamic rooting (User Record) setting is not working in Nakisa OrgChart SP3

    Dear All
    The Dynamic rooting setting is not working in the Nakisa OrgChart SP3.
    It is giving an error message - "Cannot find the root of your orgchart. The orgchart box may have been deleted or incorrectly specified, or no valid org structure can be found for the selected effective date. Please change the root of the chart or select another effective date."
    We followed the same steps as given in the Admin guide of SP3 (P.no. 109 - shown below)
    In Orgchart --> General Settings:
    * Select the Org chart root value source.
    User Record: Retrieves the record specified in the next step from the employee data element.
    *Do one of the following to define the org chart root:
    If User Record was selected in the previous step, select the field containing the ID of the required organizational object in the employee data element from the User record field drop-down list. For example, if you wish to root the org chart at the org unit of the logged-in user, select the field containing the org unit ID. Hence, we have selected the Org unit ID.
    Note:
    We had enabled single sign-on with logon tickets
    Retained the standard settings in Security Settings --> Employee Source
    Had provided full authorization to the roles
    If we use the "OrgChart Root" option available in 'Orgchart root value source', the org structure gets displayed correctly from the root object defined.
    As this is an standard functionality, Kindly guide us in resolving the issue.
    Regards
    Ravindra

    Ravindra.
    You don't have to and shouldn't always include the username and password parameters for the SAP Connection string.  When you omit them it will use the user's login credentials.
    Remember though that:
    The SAPRoleMappingConnection will need them included in order to get the details for the user in the first place.
    Without the username and password specified in a connection string you can't click the option to test the connection and result in a successful connection.  Remember unable to connect does not necessarily equate to wrongly configured.
    I've filtered the log file for errors and the following entries were flagged up:
    26 Jun 2012 10:00:06 ERROR com.nakisa.Logger  - com.nakisa.framework.utility.Files : deleteFile : java.io.IOException: Unable to delete file: E:\usr\sap\D15\J00\j2ee\cluster\apps\Nakisa\OrgChart\servlet_jsp\OrgChart\root\.system\Admin_Config\__000__THY_SAP_Live_RFC_01\AppResources\attr.txt
    26 Jun 2012 13:13:52 ERROR com.nakisa.Logger  - com.nakisa.framework.utility.Files : deleteFile : java.io.IOException: Unable to delete file: E:\usr\sap\D15\J00\j2ee\cluster\apps\Nakisa\OrgChart\servlet_jsp\OrgChart\root\.system\Admin_Config\__000__THY_SAP_Live_RFC_01\AppResources\attr.txt
    26 Jun 2012 13:43:49 ERROR com.nakisa.Logger  - java.lang.reflect.InvocationTargetException
    26 Jun 2012 13:55:09 ERROR com.nakisa.Logger  - com.nakisa.framework.utility.Files : deleteFile : java.io.IOException: Unable to delete file: E:\usr\sap\D15\J00\j2ee\cluster\apps\Nakisa\OrgChart\servlet_jsp\OrgChart\root\.system\Admin_Config\__000__THY_SAP_Live_RFC_01\AppResources\attr.txt
    26 Jun 2012 14:32:03 ERROR com.nakisa.Logger  - com.nakisa.framework.utility.Files : deleteFile : java.io.IOException: Unable to delete file: E:\usr\sap\D15\J00\j2ee\cluster\apps\Nakisa\OrgChart\servlet_jsp\OrgChart\root\.system\Admin_Config\__000__THY_SAP_Live_RFC_01\AppResources\attr.txt
    26 Jun 2012 15:47:44 ERROR com.nakisa.Logger  - BAPI_SAP_OTFProcessor_LinkedDataElement : The dataelement ( SAPPositionVacancyDataElement ) is not defined.
    26 Jun 2012 15:47:44 ERROR com.nakisa.Logger  - BAPI_SAP_OTFProcessor_LinkedDataElement : while trying to invoke the method com.nakisa.framework.data.Command.getType() of an object loaded from local variable 'p_cmd'
    26 Jun 2012 15:47:44 ERROR com.nakisa.Logger  - com.nakisa.framework.webelement.charting.data.ChartingData : createNodesFromData : Notes Error: NullPointerException
    26 Jun 2012 15:47:44 ERROR com.nakisa.Logger  - BAPI_SAP_OTFProcessor_LinkedDataElement : The dataelement ( SAPPositionVacancyDataElement ) is not defined.
    26 Jun 2012 15:47:44 ERROR com.nakisa.Logger  - BAPI_SAP_OTFProcessor_LinkedDataElement : while trying to invoke the method com.nakisa.framework.data.Command.getType() of an object loaded from local variable 'p_cmd'
    26 Jun 2012 15:47:44 ERROR com.nakisa.Logger  - com.nakisa.framework.webelement.charting.data.ChartingData : createNodesFromData : Notes Error: NullPointerException
    26 Jun 2012 15:47:48 ERROR com.nakisa.Logger  - com.nakisa.framework.webelement.charting.data.ChartingData : createNodesFromData : Notes Error: NullPointerException
    26 Jun 2012 15:47:55 ERROR com.nakisa.Logger  - BAPI_SAP_OTFProcessor_LinkedDataElement : The dataelement ( SAPPositionVacancyDataElement ) is not defined.
    26 Jun 2012 15:47:55 ERROR com.nakisa.Logger  - BAPI_SAP_OTFProcessor_LinkedDataElement : while trying to invoke the method com.nakisa.framework.data.Command.getType() of an object loaded from local variable 'p_cmd'
    26 Jun 2012 15:47:55 ERROR com.nakisa.Logger  - com.nakisa.framework.webelement.charting.data.ChartingData : createNodesFromData : Notes Error: NullPointerException
    At the very least it looks like SAPPositionVacancyDataElement is missing and whilst the other errors around it are unfamiliar I wonder if it might be a good first step to see if you can track down the reference to and existence of this data element?  That being said it looks like your last test occurred well over an hour after this (so you may have already resolved it) and resulted in nothing but information messages.  If that is the case it might be worth "rolling" your log file or manually trimming it to the right time frame when posting it?  Otherwise it can be misleading as people could flag up issues you have already resolved.
    So assuming you haven't tried Luke's suggestion (which should only take a couple of minutes to do) I think you should go back and do so right away .
    Regards,
    Stephen.

  • Returning a result set/record from a dynamic query

    There seems to be plenty of examples for using Native Dynamic Sql to formulate and execute a dynamic query, however there are no examples of returning a result set or records which contain the rows of data that are retrieved by executing the query. Could someone give us an example?

    Welcome to the Oracle forum....
    CREATE OR REPLACE PACKAGE curspkg_join AS
    TYPE t_cursor IS REF CURSOR ;
    Procedure open_join_cursor1 (n_EMPNO IN NUMBER, io_cursor IN OUT t_cursor);
    END curspkg_join;
    Create the following Oracle package body on the Oracle server:
    CREATE OR REPLACE PACKAGE BODY curspkg_join AS
    Procedure open_join_cursor1 (n_EMPNO IN NUMBER, io_cursor IN OUT t_cursor)
    IS
    v_cursor t_cursor;
    BEGIN
    IF n_EMPNO <> 0
    THEN
    OPEN v_cursor FOR
    SELECT EMP.EMPNO, EMP.ENAME, DEPT.DEPTNO, DEPT.DNAME
    FROM EMP, DEPT
    WHERE EMP.DEPTNO = DEPT.DEPTNO
    AND EMP.EMPNO = n_EMPNO;
    ELSE
    OPEN v_cursor FOR
    SELECT EMP.EMPNO, EMP.ENAME, DEPT.DEPTNO, DEPT.DNAME
    FROM EMP, DEPT
    WHERE EMP.DEPTNO = DEPT.DEPTNO;
    END IF;
    io_cursor := v_cursor;
    END open_join_cursor1;
    END curspkg_join;
    Dim Oraclecon As New OracleConnection("Password=pwd;" & _
    "User ID=uid;Data Source=MyOracle;")
    Oraclecon.Open()
    Dim myCMD As New OracleCommand()
    myCMD.Connection = Oraclecon
    myCMD.CommandText = "curspkg_join.open_join_cursor1"
    myCMD.CommandType = CommandType.StoredProcedure
    myCMD.Parameters.Add(New OracleParameter("io_cursor", OracleType.Cursor)).Direction = ParameterDirection.Output
    myCMD.Parameters.Add("n_Empno", OracleType.Number, 4).Value = 123
    Dim myReader As OracleDataReader
    Try
    myCMD.ExecuteNonQuery()
    Catch myex As Exception
    MsgBox(myex.Message)
    End Try
    myReader = myCMD.Parameters("io_cursor").Value
    Dim x, count As Integer
    count = 0
    Do While myReader.Read()
    For x = 0 To myReader.FieldCount - 1
    Console.Write(myReader(x) & " ")
    Next
    Console.WriteLine()
    count += 1
    Loop
    MsgBox(count & " Rows Returned.")
    myReader.Close()
    Oraclecon.Close()
    The above code is working in one of our application; which is using ref cursor as result set and get from procedure. I hope you can found more code by google and/or search in this forum as well; if above code is not useful to you.
    HTH
    Girish Sharma

  • How to make this work selecting advanced record set dreamweaver complains and crashes all the time

    Hi There
    I have met a person who does php and sql work but not with dreamweaver. The code I have works but dreamweaver shows me an error with my record sets and it crash all the time.
    <?php require_once('../Connections/datexdatabase.php'); ?>
    <?php
    if (!function_exists("GetSQLValueString")) {
    function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
      if (PHP_VERSION < 6) {
        $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
      $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
      switch ($theType) {
        case "text":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;   
        case "long":
        case "int":
          $theValue = ($theValue != "") ? intval($theValue) : "NULL";
          break;
        case "double":
          $theValue = ($theValue != "") ? doubleval($theValue) : "NULL";
          break;
        case "date":
          $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
          break;
        case "defined":
          $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
          break;
      return $theValue;
    if($_GET['pageID']==''){
        $pageId = 1;
    }else{
        $pageId = $_GET['pageID'];
    mysql_select_db($database_datexdatabase, $datexdatabase);
    $query_rsIndex = "SELECT pages.title, pages.meta_keywords, pages.meta_description, content.header, content.`description`
    FROM pages INNER JOIN content ON pages.id = content.page_id WHERE pages.id = ".$pageId." ORDER BY content.order";
    $rsIndex = mysql_query($query_rsIndex, $datexdatabase) or die(mysql_error());
    $row_rsIndex = mysql_fetch_assoc($rsIndex);
    $totalRows_rsIndex = mysql_num_rows($rsIndex);
    ?>
    <?php do { ?>
            <?php if($row_rsIndex['header'] != 'Introduction'){ ?>
            <b><?php echo $row_rsIndex['header']; ?></b>
            <?php } ?>
            <p><?php echo$row_rsIndex['description']; ?></p>
            <?php } while ($row_rsIndex = mysql_fetch_assoc($rsIndex)); ?>
    <?php
    mysql_free_result($rsIndex);
    ?>
    I am able to join the tables in the advanced recordset but i am getting confused with "" FROM pages INNER JOIN content ON pages.id = content.page_id WHERE pages.id = ".$pageId." ORDER BY content.order";"
    mysql_select_db($database_datexdatabase, $datexdatabase);
    $query_rsIndex = "SELECT pages.title, pages.meta_keywords, pages.meta_description, content.header, content.`description`
    FROM pages INNER JOIN content ON pages.id = content.page_id WHERE pages.id = ".$pageId." ORDER BY content.order";
    My question is how can I use dreamweaver with the advanced recordset with the pageID without dreamweaver crashing 20 times a day
    Regards

    My question is how can I use dreamweaver with the advanced recordset with the pageID without dreamweaver crashing 20 times a day
    Do you get any errors in Dreamweaver when it crashes?
    What version?
    What OS?
    Have you tried trashing recreating the user config folder ( http://kb2.adobe.com/cps/405/kb405604.html#main_user_config )?
    Have you tried trashing the preferences ( http://kb2.adobe.com/cps/839/cpsid_83912.html )?
    Has anything changed on the system recently (from program installs, to system / OS updates)?
    Have you tried creating a new user account on the system to verify there is no corruption in the current user's system data?

  • "File Dialog" Express VI returns the wrong path when the user selects the desktop

    In labview 8.0.1 with Windows
    XP, the File Dialog Express VI seems to return something other than the path
    selected by the user when configured to browse for folders (or files and
    folders) and the user selects the desktop.
    I can't determine exactly when it works and when it fails, but it always seems
    to fail if the user selects the desktop from the places bar (the shortcuts on
    the left side of the dialog) or from the drop-down menu at the top of the
    dialog and then clicks the "Current Folder" button to dismiss the
    dialog.  In this case it always returns whatever path is wired to the
    "Start Path" terminal.
    If the user navigates to the desktop with the "Up One Level" button
    or by selecting the actual desktop directory under Documents and Settings, the
    correct path is returned.
    If the user selects a file before clicking the desktop icon, then clicks
    "Current Folder" the correct path is returned.
    If the user clicks the desktop icon, clicks open, then clicks "Current
    Folder" the correct path is returned.
    It's possible to work around this bug in most cases by setting the start path
    to the desktop.
    Has anyone seen this behavior before?
    Can anybody verify this behavior by running the attached VI?
    In the past, when I've reported issues like this I've received responses from
    NI engineers that basically said "Thanks, but we already knew
    that".  Is there anywhere that users can search the list of known
    bugs and avoid wasting time tracking down issues that are already understood by
    NI?
    Thanks,
    Adam Brewster
    Attachments:
    File Dialog Test.vi ‏39 KB

    I'm on 8.2 and I can't get it to fail no matter how I select the desktop. I haven't tried it in 8.0, but I imagine that if this really is a bug, they did know about it and fixed it with 8.2. If this causes a real problem for you, I would suggest upgrading if you can.

  • Filtering users based on return of past query

    Greetings!
    We have a Users table with over 3 million user records in it (like a data warehouse). The requirement is to execute 2 queries on the Users table, where the return of the second query should not have any users that were returned in the first query.
    For e.g. Consider a sweepstake user-list, where you want to send flyers to people, notifying them about prizes, but do not want to send two flyers to the same person, even if he fulfills the selection criteria for both the sweepstakes.
    So -
    Query.1. has conditions, which state: All Users from New York, with age=25 (independently run, returns 500,000 users)
    Query.2. has conditions, which state: All Users of age=25 (independently run, returns 700,000 users)
    Expected Output:
    Query 1 should return 500,000
    Query 2 should return 700,000 MINUS those users that were already returned in Query 1. i.e. Only return all users of age 25, but who are not from New York
    Any inputs will be much appreciated!
    Thanks,

    Given that you know that the first query uses state = NY and age = 25, why can't you do the second query as:
    SELECT * FROM table
    WHERE age = 25 and
          state <> 'NY'John

Maybe you are looking for