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 (全て見る)
- python : pyscript - 2022年5月16日
- python : logging モジュールの使い方 - 2022年5月16日
- 機械名:号機:顧客番号 - 2022年2月17日