1 2 3 4 5 6 7 8 9 10 11 12 13 |
#(14)データの並び替え order by -- (1)price を降順(desc)で並び替える select * from products order by price desc; -- (2)price を昇順(asc)で並び替える select * from products order by price asc; #デフォルトがascなので省略可能 -- (3)priceを降順(desc)で並べて、価格が同じときは登録順(id順)で並び替える select * from products order by price desc , id asc; -- (4)ユーザーを生年月日が古い順に並べる。一緒の場合は都道府県idで昇順に並べる。 select * from users order by birthday asc , prefecture_id asc; #記述順序:select>from>where>group by>having>order by>limit #実行順序:from>where>group by>select>having>orderby>limit #selectの順序だけが異なることに注意 |
The following two tabs change content below.
Keita N
最新記事 by Keita N (全て見る)
- Freenove ESP32-WROVER Board CAMを購入しました。その2 - 2023年11月4日
- Freenove ESP32-WROVER Board CAMを購入しました。 - 2023年11月4日
- ANOGAN 第一話 - 2023年6月16日