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‘€�ì insert�Aupdate�Awhere�Ahaving�Adistinct

Šî–{“I‚É Oracle�ASQL-Server�AMDB ‚Å‹¤’ʂł·�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�[ƒh�C�³

/* Šî–{Œ^ */
  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');

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

�¡SQL Šî‘b•ÒŽ‘—¿
�¡SQL Šî‘bŽÀ’n•ÒŽ‘—¿
�¡SQL ƒ`ƒ…�[ƒjƒ“ƒO•ÒŽ‘—¿
�¡Oracle PL/SQL •ÒŽ‘—¿
�¡PostgreSQL •Ò�AJAVA Servlet�AJSP •ÒŽ‘—¿
�¡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-2018 Y.SAK