SAK }‘ŠÙ

SAK Streets ƒƒCƒ“ƒXƒgƒŠ[ƒg }‘ŠÙEƒJƒtƒF ˆê—— SAK Streets ŒŸõ
| VB | SQL | Perl | PHP | ASP | JSP | C | PC | HP | FAQ | ƒtƒŠ[ƒ\ƒtƒg |

SQL Šî‘b•Ò (‚»‚ÌŽµ) ƒŒƒR[ƒh‘€ì insertAupdateAwhereAhavingAdistinct

Šî–{“I‚É OracleASQL-ServerAMDB ‚Å‹¤’Ê‚Å‚·B

¡ƒŒƒR[ƒh’ljÁ

/* Šî–{Œ^ */
  insert into sak.Žó’m (Žó’”Ô†, •i”Ô, ...)
    values ('000001-001', 'a001', ...);

/* –â‚¢‡‚킹ƒf[ƒ^‚ð’ljÁ */
  insert into sak.Žó’w1
    select * from sak.Žó’m where •i”Ô = 'a001';

¡ƒŒƒR[ƒhC³

/* Šî–{Œ^ */
  update sak.Žó’m set •i”Ô = 'a001', Žó’” = 100
    where Žó’”Ô† = '000001-001';

/* –â‚¢‡‚킹ƒf[ƒ^‚ÅC³ */
  update sak.Žó’m set
    •i”Ô = select •i”Ô from ...
    where Žó’”Ô† = '000001-001';

/* •¡”€–Ú‚ð–â‚¢‡‚킹ƒf[ƒ^‚ÅC³ */
  update sak.Žó’m set
    (•i”Ô, Žó’”) = (select •i”Ô, Žó’” from ...)
    where Žó’”Ô† = '000001-001';

¡ƒŒƒR[ƒh–â‚¢‡‚킹

/* Šî–{Œ^ */
  select * from sak.Žó’m
    where •i”Ô = 'a001'
    order by Žó’”Ô†;

/* ’ŠoðŒ‚É”’l”͈͂ðŽw’è */
  select * from sak.Žó’m
    where Žó’” between 100 and 200
    order by Žó’”Ô†;

/* WŒv–â‚¢‡‚킹Œ‹‰Ê‚É’ŠoðŒ‚ðŽw’è */
  select “¾ˆÓæCD, •i”Ô, sum(Žó’”) as Žó’Œv from sak.Žó’m
    where “¾ˆÓæCD = '1000' or “¾ˆÓæCD = '2000'
    group by “¾ˆÓæCD, •i”Ô
    having sum(Žó’”) > 300
    order by “¾ˆÓæCD, •i”Ô;

/* •¶Žš—ñ”äŠr‚ɃƒCƒ‹ƒhƒJ[ƒh(%) ‚ðŽw’è */
  select * from sak.Žó’m
    where Žó’”Ô† like '1%'
    order by Žó’”Ô†;

/* •¶Žš—ñ”äŠr‚ɃƒCƒ‹ƒhƒJ[ƒh(_) ‚ðŽw’è */
  select * from sak.Žó’m
    where Žó’”Ô† like '1_____-001'
    order by Žó’”Ô†;

/* d•¡ƒŒƒR[ƒhœ‹ŽŽw’è */
  select distinct •i”Ô from sak.Žó’m order by •i”Ô;

/* ƒŒƒR[ƒhŒ” */
  select count(*) from sak.Žó’m;

¡ƒŒƒR[ƒh•¡‡–â‚¢‡‚킹

/* •›–â‚¢‡‚킹‚Ɉê’v‚·‚é–â‚¢‡‚킹 */
  select * from sak.Žó’m
    where •i”Ô in
    (select distinct •i”Ô from sak.•i”Ôm where •i”Ô = 'a001');

/* •›–â‚¢‡‚킹‚Ɉê’v‚·‚é‚à‚̈ȊO‚Ì–â‚¢‡‚킹 */
  select * from sak.Žó’m
    where •i”Ô not in
    (select distinct •i”Ô from sak.•i”Ôm where •i”Ô = 'a001');

/* •›–â‚¢‡‚킹‚É‚Ì‚¢‚¸‚ê‚©‚æ‚è‘å‚«‚¢–â‚¢‡‚킹 */
  select * from sak.Žó’m
    where •i”Ô > any
    (select distinct •i”Ô from sak.•i”Ôm where •i”Ô = 'a001');

/* •›–â‚¢‡‚킹‚É‚Ì‘S‚Ä‚æ‚è‘å‚«‚¢–â‚¢‡‚킹 */
  select * from sak.Žó’m
    where •i”Ô > all
    (select distinct •i”Ô from sak.•i”Ôm where •i”Ô = 'a001');

/* •›–â‚¢‡‚킹‚©‚çAX‚É–â‚¢‡‚킹 */
  select * from
    (select * from sak.Žó’m where •i”Ô = 'a001')
    where Žó’” > 100;

¡SQL Šî‘b•ÒŽ‘—¿
¡SQL Šî‘bŽÀ’n•ÒŽ‘—¿
¡SQL ƒ`ƒ…[ƒjƒ“ƒO•ÒŽ‘—¿
¡Oracle PL/SQL •ÒŽ‘—¿
¡PostgreSQL •ÒAJAVA ServletAJSP •ÒŽ‘—¿
¡MySQL •ÒŽ‘—¿
| VB | SQL | Perl | PHP | ASP | JSP | C | PC | HP | FAQ | ƒtƒŠ[ƒ\ƒtƒg |

SAK Streets ƒƒCƒ“ƒXƒgƒŠ[ƒg }‘ŠÙEƒJƒtƒF ˆê—— SAK Streets ŒŸõ



Copyright (C) 1999-2024 Y.SAK