Query with criteria?

Here's my problem...
I have a table that I am using for a forum. I have the following fields in table...
username
datepost
post
postby
subject
Whenever somebody posts a new topic - a new record with a new subject is created. Whenever somebody responds to a post - a new record with an already existing subject is created - anotherwards I am grouping the records by subject so when a user views a topic the original post will display and all responses will display by setting the query to "select * from .... where subject like ...."
My problem is on the forum home page I have a table and I want to set the query to display all the subjects, but only once...anotherwards for each subject I just want to display the oldest record because that record will be the original post and yes datepost is type DATE/TIME in MySQL. I know that I could add a field to this table and do something like everytime a new topic is posted set the new field to 1 and then set all replies to set the new field to 2 and then I could just use this new field in the query to solve my problem, but I DON'T WANT TO ADD A FIELD TO THE TABLE. So does anybody know how I can solve this problem without changing the table?
Thanks in advance.

I wonder if my forum etiquette is wrong or something because alot of my posts go unanswered, but either way I solved my problem. I did end up making a new table fields follow...
screenname varchar
date date/time (MySQL Date/Time)
topic varchar
originator varchar (probably should be boolean to be most efficient and follow best practices, but I was lazy!)
post text
notes text (Really just an extra field for admin use)
forumid varchar
Here's how it works...
originator field is updated with char 1 for an originating post...anotherwards when a new topic is created that record gets a 1 in this field...The reason I do this is so when somebody wants to view a post I have to identify one of the records as the originating post and I also need a way to query for only unique topics that are originating post so all replies get char 0 in this field. Now when a client goes to forum home page they will see table with all original posts and the table is not filled with any replies. The table has a hyperlink component for topic that returns a second page with a different query that DOES display FIRST the originating post and then all replies in ASC order by Date. Another note is that I have 2 Forums so I used forumid to identify posts from the two different forums. I have never built a forum before and I have no doubt that I will find problems with this setup, but so far it's all working well. Now if anybody can tell me how to replaceAll /n with <br> to display carriage returns in table...I would be grateful!

Similar Messages

  • Query with criteria in unbound item

    Hi,
    I have a block (master) related to another block (detail). I'd like to narrow the returned results by adding a criteria in an unbound item in the master block.
    The value in the unbound item seemed to be ignored when I execute the query.
    How can I add a criteria for my query ?
    Thank you...

    If it's a simple value then add in a pre-query trigger onto the detail block with something like :
    begin
    if :control.my_unbound_item is not null then
    :detail.the_item := :control.unbound_item;
    end if;
    end;
    If you need something more sophisticated then post an example of what you'd like to do.
    Regards,
    Steve

  • Select some attributes with criteria api

    Hi,
    How can I specify more than one attribute here:
    query.select((Selection<? extends E>) root.get("name"));
    in other words, how can i get this query with criteria api "select name, second_name from Person" ?
    Thank you!

    Hi,
    How can I specify more than one attribute here:
    query.select((Selection<? extends E>) root.get("name"));
    in other words, how can i get this query with criteria api "select name, second_name from Person" ?
    Thank you!

  • Re-query with last criteria programmatically

    I need to re-query a block with criteria from last query
    (after having changed the block's order by-clause), that is
    I need to do something equivalent to calling ENTER_QUERY
    twice followed by EXECUTE_QUERY.
    Anyone done something like this?

    There is a block property called LAST_QUERY.
    You have to extract the where-clause from there and set it as the default-where.

  • How can I create a query with web service data control?

    I need to create a query with web service data control, in WSDL, it's query operation, there is a parameter message with the possible query criteria and a return message contains the results. I googled, but cannot find anything on the query with web service. I cannot find a "Named Criteria" in web service data control like normal data control. In Shay's blog, I saw the topics on update with web service data control. How can I create a query with web service data control? Thanks.

    Hi,
    This might help
    *054.     Search form using ADF WS Data Control and Complex input types*
    http://www.oracle.com/technetwork/developer-tools/adf/learnmore/index-101235.html

  • Need help in optimizing the query with joins and group by clause

    I am having problem in executing the query below.. it is taking lot of time. To simplify, I have added the two tables FILE_STATUS = stores the file load details and COMM table that is actual business commission table showing records successfully processed and which records were transmitted to other system. Records with status = T is trasnmitted to other system and traansactions with P is pending.
    CREATE TABLE FILE_STATUS
    (FILE_ID VARCHAR2(14),
    FILE_NAME VARCHAR2(20),
    CARR_CD VARCHAR2(5),
    TOT_REC NUMBER,
    TOT_SUCC NUMBER);
    CREATE TABLE COMM
    (SRC_FILE_ID VARCHAR2(14),
    REC_ID NUMBER,
    STATUS CHAR(1));
    INSERT INTO FILE_STATUS VALUES ('12345678', 'CM_LIBM.TXT', 'LIBM', 5, 4);
    INSERT INTO FILE_STATUS VALUES ('12345679', 'CM_HIPNT.TXT', 'HIPNT', 4, 0);
    INSERT INTO COMM VALUES ('12345678', 1, 'T');
    INSERT INTO COMM VALUES ('12345678', 3, 'T');
    INSERT INTO COMM VALUES ('12345678', 4, 'P');
    INSERT INTO COMM VALUES ('12345678', 5, 'P');
    COMMIT;Here is the query that I wrote to give me the details of the file that has been loaded into the system. It reads the file status and commission table to show file name, total records loaded, total records successfully loaded to the commission table and number of records that has been finally transmitted (status=T) to other systems.
    SELECT
        FS.CARR_CD
        ,FS.FILE_NAME
        ,FS.FILE_ID
        ,FS.TOT_REC
        ,FS.TOT_SUCC
        ,NVL(C.TOT_TRANS, 0) TOT_TRANS
    FROM FILE_STATUS FS
    LEFT JOIN
        SELECT SRC_FILE_ID, COUNT(*) TOT_TRANS
        FROM COMM
        WHERE STATUS = 'T'
        GROUP BY SRC_FILE_ID
    ) C ON C.SRC_FILE_ID = FS.FILE_ID
    WHERE FILE_ID = '12345678';In production this query has more joins and is taking lot of time to process.. the main culprit for me is the join on COMM table to get the count of number of transactions transmitted. Please can you give me tips to optimize this query to get results faster? Do I need to remove group and use partition or something else. Please help!

    I get 2 rows if I use my query with your new criteria. Did you commit the record if you are using a second connection to query? Did you remove the criteria for file_id?
    select carr_cd, file_name, file_id, tot_rec, tot_succ, tot_trans
      from (select fs.carr_cd,
                   fs.file_name,
                   fs.file_id,
                   fs.tot_rec,
                   fs.tot_succ,
                   count(case
                            when c.status = 'T' then
                             1
                            else
                             null
                          end) over(partition by c.src_file_id) tot_trans,
                   row_number() over(partition by c.src_file_id order by null) rn
              from file_status fs
              left join comm c
                on c.src_file_id = fs.file_id
             where carr_cd = 'LIBM')
    where rn = 1;
    CARR_CD FILE_NAME            FILE_ID           TOT_REC   TOT_SUCC  TOT_TRANS
    LIBM    CM_LIBM.TXT          12345678                5          4          2
    LIBM    CM_LIBM.TXT          12345677               10          0          0Using RANK can potentially produce multiple rows to be returned though your data may prevent this. ROW_NUMBER will always prevent duplicates. The ordering of the analytical function is irrelevant in your query if you use ROW_NUMBER. You can remove the outermost query and inspect the data returned by the inner query;
    select fs.carr_cd,
           fs.file_name,
           fs.file_id,
           fs.tot_rec,
           fs.tot_succ,
           count(case
                    when c.status = 'T' then
                     1
                    else
                     null
                  end) over(partition by c.src_file_id) tot_trans,
           row_number() over(partition by c.src_file_id order by null) rn
    from file_status fs
    left join comm c
    on c.src_file_id = fs.file_id
    where carr_cd = 'LIBM';
    CARR_CD FILE_NAME            FILE_ID           TOT_REC   TOT_SUCC  TOT_TRANS         RN
    LIBM    CM_LIBM.TXT          12345678                5          4          2          1
    LIBM    CM_LIBM.TXT          12345678                5          4          2          2
    LIBM    CM_LIBM.TXT          12345678                5          4          2          3
    LIBM    CM_LIBM.TXT          12345678                5          4          2          4
    LIBM    CM_LIBM.TXT          12345677               10          0          0          1

  • Bug in Entity Framework: No rows returned with criteria.

    Bug: Oracle fails to return rows with lambda criteria on string field from varchar2 column in view.
    Steps to reproduce:
    Create view:
    CREATE OR REPLACE VIEW "PHILIP_TEST" ("ROWNUMBER", "DRIVER") AS
    SELECT
         ROWNUMBER,
         DECODE(DRIVER,CHR(2),NULL,DRIVER) DRIVER
    FROM FLIGHT
    WHERE SCHEDULEDDATE = TRUNC(SYSDATE);
    Rownumber is unique key (number), Driver is varchar2(7).
    Create C# console application in VS2010
    Add Entities Model and add view.
    Add this code to Main()
    var context = new Entities();
    // Test code start
    var allrows = context.PHILIP_TEST.Where(x => x.DRIVER != null).ToArray();
    Console.WriteLine(allrows.Count());
    // Select first driver as criteria
    var driver = allrows[0].DRIVER;
    Console.WriteLine(driver);
    // Test code end
    // This line fails to return any rows
    var result = context.PHILIP_TEST.Where(x => x.DRIVER == driver).ToArray();
    Console.WriteLine(result.Count());
    Console.ReadLine();
    Add some test data to flight.
    Run it!
    The expression with criteria x.DRIVER == driver should return at least 1 row. It doesnt.
    Running the following from SQL Developer returns records: Conclution the view is fine.
    SELECT * FROM PHILIP_TEST WHERE DRIVER = 'MJA'
    If definition of DRIVER column in view is changed from: "DECODE(DRIVER,CHR(2),NULL,DRIVER) DRIVER" to just "DRIVER", then code returns rows as expected.

    are you sure your two select statements can't be combined to one query with outer join?
    if the outer join is possible, after creating the query, it will have one group with all the fields/columns you selected.
    drag the columns you selected in the personal info, outside the group.
    this should enable you to have one query with two groups, a master (personal info) and a detail (monetary calculations).
    your first frame will have the master group as source, while for the second the detail. now, the "Value if Null" should work.
    if the outer join is not possible,
    create one query with only the personal info. in the group, create column formula to get the monetary columns (you may need to create place holders if selecting multiple columns)
    drag the columns you selected in the personal info, outside the group.
    this should enable you to have one query with two groups, a master (personal info) and a detail (monetary calculations, you CF_ and CP_ columns).
    your first frame will have the master group as source, while for the second the detail. now, the "Value if Null" should work in your CF_ and CP_ columns

  • Af:query with bind variables and Saved Search

    I have a VO and view criteria(VC).
    VC has a criteria item ObsoleteDate with range specified as bindVariables "dateFrm" and "dateTo" I dragged & dropped the named criteria as af:Query with table. Table toolbar has 2 buttons in which I set & clear the bind variables. Data is fetched as per as expected based on the VC & bind variables.
    The problem is,
    If I save my search with bind variables set and swap between the saved searches , all works fine. But the moment I clear bind variables & swap between searches.. "dateFrm" is populated and "dateTo" is null and I get an Exception oracle.jbo.AttrValException: JBO-27035: Attribute Obsolete Date: is required.
    Why is this happening?? Saved search is supposed to save the VC with all the bind values set while saving and clearing bind variables shouldn't affect the saved search, right?? Or I have understood it wrong?
    I am using JDeveloper 11.1.2.3.0
    Thanks

    Try
    like ? || '%'

  • LOV with Criteria problem

    Hi, I'm using JDEV11.1.1.2
    I have a View object used for LOV
    select kod, element, text  <- lov query
           from tableAwith a ViewCriteria that filters the query with bind Var:
    ( KOD  = :kod )   <-- this is the view criteriaI have assinged this lov to a field of another view and set the bindVar to be a static string 'YYY'.
    Everything works as expected, except in one rare case:
    I open the page and without calling the LOV, I enter some existing key in the lov field manually. When I press Enter the following error occurs:
    java.sql.SQLException: Attempt to set a parameter name that does not occur in the SQL: kod
    If i first open the lov popup and close it - manual entered keys are working as expected. It seems like it needs the lov to be called (initialized) and then I can work with it with manually entering values.
    Is there something i can do to fix this case, because it maybe not so rare for the customer, who knows the codes and does not need to call the lov popup at all.
    Thank you

    Hi, I'm using JDEV11.1.1.2
    I have a View object used for LOV
    select kod, element, text  <- lov query
           from tableAwith a ViewCriteria that filters the query with bind Var:
    ( KOD  = :kod )   <-- this is the view criteriaI have assinged this lov to a field of another view and set the bindVar to be a static string 'YYY'.
    Everything works as expected, except in one rare case:
    I open the page and without calling the LOV, I enter some existing key in the lov field manually. When I press Enter the following error occurs:
    java.sql.SQLException: Attempt to set a parameter name that does not occur in the SQL: kod
    If i first open the lov popup and close it - manual entered keys are working as expected. It seems like it needs the lov to be called (initialized) and then I can work with it with manually entering values.
    Is there something i can do to fix this case, because it maybe not so rare for the customer, who knows the codes and does not need to call the lov popup at all.
    Thank you

  • Query selection criteria - changing description field..?

    Hi Experts,
    i want to change description filed in user query selection criteria form..
    i have 3 fileds  :
    docdate - this filed i want to chage 'Document First'
    docdate - This filed i want to change 'Document Last'
    name -
    my problem: screenshot
    [Click Here|http://img638.imageshack.us/img638/3466/userqueris.jpg]

    The system always asks with the description of the field you refer to with the parameter variable in the select statement.
    I sometimes defined a UDT only for getting the appropriate title in the parameter entering window. The table has no data; I used it only for its field names.
    (The parameter request can be placed inside a comment and the entered value is used setting an SQL variable like this:
    declare @d datetime
    /*select t.createdate from ordr t where t.createdate=[%0]*/
    set @d=[%0]
    This SQL variable can be used later in the real query.)
    (But then you loose the possibility to choose from the u2018List of existing valuesu2019

  • How to Transpose the Query with following result

    Dear All,
    Can anyone tell me a method of transposing my result of the following query
    Details can be found at
    http://obiee11ge.blogspot.com/2010/07/how-to-transpose-query-with-following.html
    Regards
    Mustafa

    Hi,
    Try this
    Create a combined request with,
    criteria 1 : Dummy, Revenue (Actual),Cogs(Actual), Opex(Actual), PL(Actual)
    in the dummy column fx enter the value as 'Actual'
    criteria 2 : Dummy, Revenue (Yago),Cogs(YAgo), Opex(Yago), PL(Yago)
    in the dummy column fx enter the value as 'Yago'
    criteria 3 : Dummy,Revenue (Budget),Cogs(Budget), Opex(Budget), PL(Budget)
    in the dummy column fx enter the value as 'Budget'
    Now go to the result columns and set the coumn names (Revenue, Cogs, Opex, PL) for the result set.
    For the Dumny remove the column heading.
    In table view you will get the result.
    Thanks,
    Vino

  • Copy function based on the query with variables

    Hello
    Let me share the scenario I need to implement. I have a planning query with layout like shop / material / sales volume. The variables are shop number and calendar month. User opens the planning query, selects shop number and month, then sees the list of materials and puts the planned sales volume, then saves as a temporary version. Saving as a temporary version is realized by standard u201Csaveu201D function. The matter is that the user needs to have a possibility to copy this version to official one. I created the button and linked it with the copy function. The problem is that when a user clicks this button, the function asks him/her to provide variables again. I would like to have the button which copies the data with the same selection criteria as the query already has.
    Any idea?
    Arelis.

    Hi,
    I think when you add the button you specify the planning sequence name and that takes the filter of the modeler .Now when you try to call the planning sequence the filter variables are also added to the button as VAR_NAME, VAR_VALUE which prompts you for the variable again.Delete VAR_NAME,VAR_VALUE at the back of the button  manually and then save your work book.Then it will not ask for variable entry and the values that you have specified in the query filter will pass on to modeler filters.As variables are global.
    Similarly if you are using planning function then at the back of the button remove the VAR_NAME,VAR_VALUE.
    Hope this may help.
    Regards,
    Indu

  • LOV regions - possible to use several items as query-able criteria

    Hi,
    I have a question about LOV regions –
    Is it possible to have several items that are query-able criteria and result for a LOV region?
    Addition to the LOV–input-item itself, I’d like to have another item that will be used as one of the criteria’s to the LOV-query.
    I’ve defined the “Criteria Item” value for an additional item, which his “LOV Region Item” is query-able, but the value doesn’t appear in the search field,
    When entering the LOV-region.
    Do I have to add the additional criteria to the LOV by initializing the VO?
    Thanks in advance,
    Rona

    Seems lot of confusion with LOV. Well first thing to do is to go through the LOV section of Dev guide for more understanding.
    As for your questions, yes, you can have multiple items that are query-able criteria and result. You can use another item as the criteria to lov query, but it has to be a form element.
    If your criteria is set properly, you don't need to initialize VO manually.
    --Shiv                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                       

  • How to create an ABAP Query with OR logical expression in the select-where

    Hi,
    In trying to create an ABAP query with parameters. So it will select data where fields are equal to the parameters entered. The default logical expression is SELECT.. WHERE... AND.. However I want to have an OR logical expression instead of AND.. how can I attain this??
    Please help me on this.. Points will be rewarded.
    Thanks a lot.
    Regards,
    Question Man

    Hi Bhupal, Shanthi, and Saipriya,
    Thanks for your replies. But that didn't answer my question.
    Bhupal,
    You cannot just replace AND with OR in an ABAP QUERY. ABAP QUERY is a self generated SAP code. You'll just declare the tables, input parameters and output fields to be displayed and it will create a SAP standard code. If you'll try to change the code and replace the AND with OR in the SAP standard code, the system will require you to enter access key/object key for that particular query.
    Shanthi,
    Yes, that is exactly what need to have. I need to retireve DATA whenever one of the conditions was satisfied.
    Saipriya,
    Like what I have said, this is a standard SAP code so we can't do your suggestion.
    I have already tried to insert a code in the ABAP query (there's a part there wherein you can have extra code) but that didn't work. Can anybody help me on this.
    Thanks a lot.
    Points will be rewarded.
    Regards,
    Question Man

  • Error while trying to Execute the Query with Customer Exit

    Hi Experts,
           I am having a Query with Customer Exit, it is working fine for all the Employess, except for one. When i try to remove the Customer Exit it is working for her too. Below is the error i am getting.
    system error in program SAPLLRK0 and form RSRDR; CHECK_NAV_INIT_BACK
    Thanks,
    Kris.

    Hello Kris,
    Are you working with multiprovider? Please check if OSS notes 813454,840080 or 578948 are applicable in your case.
    Regards,
    Praveen

Maybe you are looking for