The method of reading the last result of the database

Updated on technology 2024-02-08
20 answers
  1. Anonymous users2024-02-05

    There is no bottom in select

    select top 1 * from table order by field 1 desc"

    order by field1 desc is to sort it in reverse order, and then check its first row, which is the last one.

    If you answer well, give points.

  2. Anonymous users2024-02-04

    The requirement is to take the last field, not the last record.

    This can be achieved using dynamic SQL as follows:

    declare @fieldname varchar(50)select @fieldname =

    select top 1

    from sysobjects o inner joinsyscolumns c on =

    where '[tablename]'

    order by desc)

    declare @sql varchar(1000)set @sql='select '+@fieldname+' from [tablename] .'

    exec(@sql)

  3. Anonymous users2024-02-03

    In the case of an oracle database:

    select * from table where rownum=(select cuont(*)form table);

    The last record of this query is the last record you entered the data in.

  4. Anonymous users2024-02-02

    while(

    If you have a problem with your loop, the loop of your database record will be finished when i=0, in this case, your loop should be 1, then there must be only the last data.

    Put gc[i].setname("name"));The following } is changed to; The front will be fine.

  5. Anonymous users2024-02-01

    <%'Database connection file ......

    <%'Read the last id value.

    sql="select id from user order by id desc "

    set rs=

    Outputs the last ID

    rs("id")

    Closing the database connection is ......

    The first floor is also correct.

  6. Anonymous users2024-01-31

    id="select max(id) from the table name")(0)

    That's the ID you want

  7. Anonymous users2024-01-30

    select * from order a, ( select order number, max (status) status from order group by order number ) b

    where a.Order number = bOrder number and aStatus = bState.

    There is a requirement that the states be sorted by this state.

    If it can't be sorted, you need something with a serial number, and you can use this serial number to get a record of the last operation.

  8. Anonymous users2024-01-29

    select

    from table main

    wherenot exists ( select 1 from table sub where main.)Order number = subOrder number and main

    Date < subDate).

    The algorithm is that for each row of data, there is no data with the same order number as the bank's order number and a date greater than the bank's date.

  9. Anonymous users2024-01-28

    You're talking about the last date.

    select * from table where (order number, date) in (select order number, max (date) from table group by order number);

  10. Anonymous users2024-01-27

    select * from table order by id desc

    The last keyword, desc, means to use reverse order.

  11. Anonymous users2024-01-26

    You have 2 query statements and 2 nsql, so the setting is contradictory, it is recommended to change it to a query statement:

    sql="select top 10 * from [dv_topic] order by topicid desc,boardid desc"

    That's it, priority topicid in reverse order and then boardid in reverse order, you try!

  12. Anonymous users2024-01-25

    Both boardid and topicid fields are available in the dv topic, right?

    nsql="select top 10 * from [dv_topic] order by boardid desc"You have this order by boardid. It would be nice to use order by topicid desc.

  13. Anonymous users2024-01-24

    Are your boardIDs and toppicIDs the same record? I don't think that query statement of yours should be written like this!

  14. Anonymous users2024-01-23

    select max(column name) from the maximum value of the table.

    select top 1 column name from table order by column name desc last value.

  15. Anonymous users2024-01-22

    There is a max function in the database that can find the maximum value of a column of -

  16. Anonymous users2024-01-21

    Click on a menu item and a jframe will pop up to display the data in the database! But it's an error! What form**?,If not** but jlabel, this can also be displayed.,It's just a little difficult to do the aesthetics I give.。

  17. Anonymous users2024-01-20

    SSH framework, automatically generate the DAO layer implementation class, call the findall() method, put it in the list collection, the page directly iterates over the collection, and then, the third one is added with an ognl expression. If you are proficient and the machine is better, it can be done in 5 minutes

  18. Anonymous users2024-01-19

    This is to read it out with resultset. Read both columns? Is it okay to read it out and add it up and then output it? Do you want to be specific**?

  19. Anonymous users2024-01-18

    Computation can be performed in the database.

    select sum(price*count) from table_name group by id;

    Then read the result with it.

  20. Anonymous users2024-01-17

    SQL writes select sum(quantity***) as alias from the table.

    You can do what JDBC wants.

Related questions
11 answers2024-02-08

select ,from emp e left jion dept don ;

Left Company. The left link is, the left side prevails, and the right side is useless to make up for it. >>>More

5 answers2024-02-08

It seems that there is something called triggers in the DB, and there seems to be another thing called transactions.