The SQL statement collects two (extracting each of the information of each of the different classes in the table) a new table)

zhaozj2021-02-16  52

Problem Description:

Table Structure

ID Title Body ClassID

1 AAAAA AFDS 1

2 BBB DSAA 1

3 CCC FDSA 2

4 DDD DASA 2

5 Eee FDSA 2

Two after the ClassID is 1, the lassid is 2 after 2

become

1 AAAAA AFDS 1

2 BBB DSAA 1

4 DDD DASA 2

5 Eee FDSA 2

solution:

SELECT * FROM

table

a where id in (SELECT TOP 2 id from

table

Where classid = a.classID)

转载请注明原文地址:https://www.9cbs.com/read-19543.html

New Post(0)