Experiment with sorting after query limit
P粉237125700
P粉237125700 2023-09-05 14:46:42
0
1
688
<p>So this is my first question here, please forgive me if something is wrong. </p> <p>I am trying to make a sort query based on constraints. </p> <p>So there is a Customers table with 90 records. </p> <p>I want to first perform a query limited to 3 records, and then sort the query results by a column called ContactName. </p> <p>I think this might be a nested query. Nested queries run fine in SQL Server, but don't know how to implement it in MySQL. </p> <p>Limit query:</p> <pre class="brush:php;toolbar:false;">Select * from customers limit 3;</pre> <p> Sort after limiting the query (my guess, but this doesn't work): </p> <pre class="brush:php;toolbar:false;">Select * from (Select * from customers limit 3) Order by ContactName;</pre> <p>Please help. Thanks. </p>
P粉237125700
P粉237125700

reply all(1)
P粉081360775

You only need this

Select * from customers Order by ContactName limit 3;
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template