mysql Äõ¸® Áú¹®

djkneg883   
   Á¶È¸ 636   Ãßõ 0    

안녕Ȣ16;세요.

mysql 쿼리에 대해서 1656;문Ȣ16;고1088; 올립니다.

아래와 같1060; 데1060;터가 1080;1012; ǐ12; code = 'A061'1068; ǐ12; count(grpNo) = 11064; id만 뽑아내고 dz10;1008;데 

group by를 Ȣ16;면서 뽑1004;/140; 해도 도1200;7176; 모르,192;네요.

id00011008; code = 'A061'1068;ǐ12; 해NJ17; 데1060;터1032; grpNo = 21064; count(grpNo) 가 3 1060;라서 뽑1648; 않고

id00021032; ᅆ1;우 grpNo = 11064; count(grpNo)가 11060;라서,

결과값1004;/196; id0002 를 뽑고 dz10;1008;데 Ǻ12;떻,172; 해야할까요? 

database에 대한 1648;식1060; 1687;아서 문1032;글1012; 남깁니다. 

idtmpCodecodedcodegrpNo
id0010002A002A0020013
id0010003A003A0030014
id0014990A006A0060012
id0010035A025A0250011
id0014991A061A0610012
id0014992A062A0620012
id0024991A061A0610011
id0030037A029A0290011
ªÀº±Û Àϼö·Ï ½ÅÁßÇÏ°Ô.
index¸¦ Çϳª »ý¼º ÇϽÃÁÒ.. Primary key µµ Áֽðí.
±×·³ ÆíÇÏ°í DB ÀÚü°¡ index °¡ ÀÖ¾î¾ß Çϴµ¥.
¾øÀ¸¸é µÎ°íµÎ°í °è¼Ó ºÒÆíÇÕ´Ï´Ù.
MySQL¿¡¼­ ½ÇÇàÇØ º¸Áö ¾Ê¾Ò´Âµ¥
´ëÃæ ÀÌ·± Äõ¸®¸¦ ¿øÇϽô µí ÇÕ´Ï´Ù.

SELECT id
FROM Å×À̺í¸í a
WHERE a.code = 'A061'
AND EXISTS (
SELECT 1
FROM Å×À̺í¸í c
WHERE c.grpNo IN (
SELECT grpNo
FROM Å×À̺í¸í b
WHERE b.id=a.id and b.code=a.code
)
AND c.id=a.id
GROUP BY grpNo
HAVING COUNT(*) = 1
)
     
djkneg883 2023-02
Á¤¸» °¨»çµå¸³´Ï´Ù. ÇØ´ç Äõ¸®·Î Çϴϱñ ¹Ù·Î ³ª¿À³×¿ä!! Á» ´õ °øºÎ¸¦ Çؾ߰ڳ׿ä
¹Î»çÀå 2023-02
Áú¹® ÀÚü°¡ ¹«½¼ ¼Ò¸®ÀÎÁö ¸ð¸£°Ú³×¿ä
     
¸»ÇÏÀÚ¸é, Äڵ尡 A061, ±×·ì³Ñ¹ö°¡ 1ÀÎ ·¹ÄÚµåÀÇ ID ¸ñ·ÏÀ» »Ì°í ½Í´Ù´Â °Å ¾Æ´Ò±î¿ä? ¹°·Ð Áߺ¹ Á¦°ÅÇÏ°í¿ä.

Àü Áú¹®Àº ÀÌÇØÇÑ °Å °°Àºµ¥ °áÁ¤ÀûÀ¸·Î DB¸¦ ¸ô¶ó¼­ ¤¾¤¾¤¾
          
¹Î»çÀå 2023-02
SELECT id FROM Å×À̺í WHERE code='A061' AND grpNo='1'

ÀÌ·¸°Ô ½¬¿î°É Áú¹®ÇϼÌÀ»¶ó³ª¿ä ?
               
¾ÆÀÌ°í.. À§ DPA¹ÚÀÎÈ£´Ô ´ñ±ÛÀ» º¸°í ´Ù½Ã Áú¹®±ÛÀ» ÀÚ¼¼È÷ º¸´Ï.. Á¦°¡ À߸ø ÀÌÇØÇß¾ú³×¿ä. ºÎ²ô·´... ¤Ð¤Ì
count ºÎºÐÀ» ³õÃƽÀ´Ï´Ù.

Äڵ尡 A061ÀÏ ¶§ÀÇ ±×·ì³Ñ¹ö°¡ ²À 1À̾î¾ß ÇÏ´Â °Ô ¾Æ´Ï¶ó..  Äڵ尡 A061ÀÏ ¶§ÀÇ ±×·ì³Ñ¹ö°¡ ¹¹°¡ µÇ¾úµç, ±× ±×·ì³Ñ¹öÀÇ °¹¼ö¸¦ Ä«¿îÆ® Çؼ­ ±×°Ô 1ÀÎ °æ¿ì¿¡¸¸ ±× ID¸¦ ÃßÃâÇÏ°í ½Í´Ù..´Â ¾ê±âÀΰ¡ º¸³×¿ä. ^^;;;

Áï, id001Àº Äڵ尡 A061ÀÏ ¶§ÀÇ ±×·ì³Ñ¹ö°¡ 2Àε¥, id001ÀÇ ·¹ÄÚµå Áß ±×·ì³Ñ¹ö°¡ 2ÀÎ °Ô µµÇÕ 3°³ ÀÖÀ¸¹Ç·Î id001Àº Å»¶ô.
id002´Â Äڵ尡 A061ÀÏ ¶§ÀÇ ±×·ì³Ñ¹ö°¡ 1Àε¥, id002ÀÇ ·¹ÄÚµå Áß ±×·ì³Ñ¹ö°¡ 1ÀÎ °Ô µü Çϳª ÀÖÀ¸¹Ç·Î ´ç÷!

ÀÌ·± ¾ê±âÀΰ¡ º¸±º¿ä.. (À̹ø¿£ Á¦´ë·Î ÀÌÇØÇß±æ.. ¤¾) ^^;; Á˼ÛÇÕ´Ï´Ù.
                    
¹Î»çÀå 2023-02
±×·¸±º¿ä. ¾î¶² Äõ¸®¶óµµ Â¥º¼¼ø Àִµ¥, Áú¹® ÀÚü°¡ ºÎÁ¤È®ÇÏ°Ô ¾²¿©À־ ´äÀ» ÇÏ°í ½Í¾îµµ ÇÒ¼ö°¡ ¾ø³×¿ä.


QnA
Á¦¸ñPage 336/437
2023-01   130   ¿¤¾²¸®
02-16   820   ¸·³»ÀÇÇÏ·ç
2023-01   3055   °Ü¿ï³ª¹«
02-15   1010   ¸ÚÁøi
2023-01   1004   choigo
02-12   723   osthek83
2023-01   1406   »ç¶ûÇ϶ó
02-10   712   ¸·³»ÀÇÇÏ·ç
2023-01   1106   ÀϹÝÀ¯Àú
02-08   1302   ÆÓ¿ùµå11
2023-01   1433   osthek83
02-07   824   L2½ºÀ§Ä¡
2023-01   1337   Åë½Åº¸¾È
02-06   759   ¹Î°æ¿­
2023-01   1223   ¹Ì½ºÆ¼
02-05   874   ¸í¶û
2023-01   1420   syhj
02-03   19   ½Å´Ù¿µ
2023-01   1052   ȸ¿ø
02-02   610   ±èÁØÀ¯