| |

VerySource

 Forgot password?
 Register
Search
View: 1747|Reply: 15

Wrong? How to read the second record

[Copy link]

2

Threads

10

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

Post time: 2020-2-6 14:00:01
| Show all posts |Read mode
How to read the second record, so I do n’t know what is wrong, please ask, thank you
sql = "select top 1 id, title, pic, path, content from info where id not in (select top 1 id from info where Commend_Top = 1 and agree = 1) and Commend_Top = 1 and agree = 1 order by addtime desc"
Reply

Use magic Report

0

Threads

64

Posts

45.00

Credits

Newbie

Rank: 1

Credits
45.00

 United States

Post time: 2020-3-25 16:30:01
| Show all posts
top 1 changed to top 2
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-3-25 18:30:02
| Show all posts
The first top1 is changed to top2
Reply

Use magic Report

0

Threads

14

Posts

8.00

Credits

Newbie

Rank: 1

Credits
8.00

 Invalid IP Address

Post time: 2020-3-25 23:15:01
| Show all posts
Because there is order by addtime desc in the outer query, and Order by addtime desc is missing in not in
correct
sql = "select top 1 id, title, pic, path, content from info where id not in (select top 1 id from info where Commend_Top = 1 and agree = 1 order by addtime desc) and Commend_Top = 1 and agree = 1 order by addtime desc "
Reply

Use magic Report

0

Threads

3

Posts

3.00

Credits

Newbie

Rank: 1

Credits
3.00

 China

Post time: 2020-3-25 23:30:01
| Show all posts
sql = "select top 2 id, title, pic, path, content from info where id not in (select top 1 id from info where Commend_Top = 1 and agree = 1) and Commend_Top = 1 and agree = 1 order by addtime desc"
Reply

Use magic Report

0

Threads

119

Posts

67.00

Credits

Newbie

Rank: 1

Credits
67.00

 China

Post time: 2020-3-25 23:45:01
| Show all posts
The inner SELECT must also be ordered by addtime desc
Reply

Use magic Report

0

Threads

38

Posts

22.00

Credits

Newbie

Rank: 1

Credits
22.00

 China

Post time: 2020-3-26 09:15:01
| Show all posts
Halo ~
Reply

Use magic Report

0

Threads

1

Posts

2.00

Credits

Newbie

Rank: 1

Credits
2.00

 China

Post time: 2020-3-26 12:15:02
| Show all posts
Upstairs solution
Reply

Use magic Report

0

Threads

322

Posts

115.00

Credits

Newbie

Rank: 1

Credits
115.00

 China

Post time: 2020-3-26 18:15:02
| Show all posts
The inner SELECT must also be ordered by addtime desc

===========

Agree, I was negligent for a while and didn't see it.
Reply

Use magic Report

2

Threads

10

Posts

11.00

Credits

Newbie

Rank: 1

Credits
11.00

 China

 Author| Post time: 2020-3-28 12:30:02
| Show all posts
Is it top1 or top2?
Reply

Use magic Report

You have to log in before you can reply Login | Register

Points Rules

Contact us|Archive|Mobile|CopyRight © 2008-2023|verysource.com ( 京ICP备17048824号-1 )

Quick Reply To Top Return to the list