logo

SQLでユーザーの削除

同じユーザー名で複数ホストがある場合に、一つのホストだけ削除するには、

select * from user where user='ユーザー名' and host='testdb';

delete from user where user='ユーザー名' and host='testdb';

One minute to read

SQLで今月の1日と月末を取得する

select * from payment_tbl where p_date between date_trunc('month',now()) and date_trunc('month',now()) + interval '1 month' - interval '1 days'; 応用 [#aa825cb0]

betweenで本日から1ヶ月前の1日から今月の月初1日の1日前の範囲を取得。 今月のデータ [#z67b048f]

One minute to read