What do I do if I want to merge rows in the database?

Updated on technology 2024-05-23
14 answers
  1. Anonymous users2024-02-11

    Mark it first, and you will post it immediately when you write it.

    I got a mysql first.。。。

    select name, date, group concat(string separator''As totalstring from test group by name, date.

    It's fairly simple, let's take a look at oracle's, since oracle doesn't have an official group string connection function, I can only write it myself.

    First of all, its own functions.

    create or replace function group str( str con1 in varchar2,str con2 in varchar2 )- categorical field.

    return varchar2

    is group_str varchar2(4000) default null;--Post-connection string.

    str varchar2(20) default null;--Connectors between strings.

    beginfor x in ( select name, date, string from test where test.)Name = str con1 and testdate = str con2 ) loop

    str_list := group_str ||str ||to_char(x.strings);

    str := '';--There are no connectors between the --strings.

    end loop;

    return group_str;

    end;How to use:

    select name, date, group str(string separator''As totalstring from test group by name, date.

    Note that this function is only useful for this test table, the disadvantage is that the first table has to write a function...

    OK, it's over.

  2. Anonymous users2024-02-10

    It seems that through the "mail merge" function, the specific operation was forgotten.

  3. Anonymous users2024-02-09

    You can connect it with a + sign in the middle.

  4. Anonymous users2024-02-08

    SQL 2005 should work with for XML.

    Multiple lines are converted to one line.

  5. Anonymous users2024-02-07

    This can be achieved by writing stored procedures.

    Table 1: T1Name Date Value: 3 January 1 aaa

    Zhang San January 1 BBB

    Zhang San January 1 CCC

    Zhang San January 2 a

    Zhang San January 2 b

    Li Si January 2 x

    Lee Si January 2 y

    The second Table 2, name, date, valuepro:

    Cursor 1 (select name, date from t1 group by name, date).

    Cursor 2 (select value from t1 a where cursor and cursor.

    Splice the value of cursor 2, and then, get the name and date of cursor 1. Insert Table II.

    That's pretty much it.

  6. Anonymous users2024-02-06

    Based on your second query, row-to-column, if the type is dynamic, it is recommended to encapsulate the stored procedure. Set a query on the outer layer and use max(case when then .end ) as 'Listing'..

    This kind of alchemist can be realized.

  7. Anonymous users2024-02-05

    Is the problem solved? I also want to achieve the effect of your third step, I don't know how you do it?

  8. Anonymous users2024-02-04

    Link the user table in one of the access databases to the user table in the other access database, and you can implement your function.

    Steps: 1. Suppose there are two access databases, and 2. there is a user table.

    3. Select the last item of the new table and connect to the user table.

    4. In this way, the data synchronization of the user table of the two access data calendar chain lead libraries can be realized.

    Above, I hope it will help you.

  9. Anonymous users2024-02-03

    This seems to have to use cursors and temporary tables, and short SQL statements can't be done by gods.

  10. Anonymous users2024-02-02

    First, add a temporary field (with duplicate flags) in Table 2, and then set the duplicate flag to the duplicate field, so that the duplicate flag field can be used as a condition when merging.

  11. Anonymous users2024-02-01

    You can write a PHP program to solve it.,Just follow what you said.。 But to know the data structure, it's best to have a test environment to guarantee that there are no errors.

  12. Anonymous users2024-01-31

    group by group join query to deduplicate.

  13. Anonymous users2024-01-30

    After exporting the tables of each Bihe database, import them one by one into the data of Xinnian Huichen.

    Or use insert into new (column1, column2, ..)select column1, column2 ..from old_;

  14. Anonymous users2024-01-29

    Take this job.

    Hi me q I 38967098

    There are a lot of details that are not clear here.

Related questions
10 answers2024-05-23

Use a conversion function, :from unixtime, to convert the timestamp to a common time format. >>>More

3 answers2024-05-23

If you are using SQL Server, open Enterprise Manager.

1.Create a database. >>>More

5 answers2024-05-23

Try to capture the return value.

4 answers2024-05-23

SQL Server syntax:

create procedure proc_name@para1 int) >>>More

3 answers2024-05-23

At least the basic things must be mastered, such as: the linear structure of the database, the storage method, the way to call Hezheng, and the operation of the table in the database (to use statements to erect the bench to achieve). >>>More