Mistři v programování na #hovnokod

Aneb jak se dela JOIN v praxi.

SELECT *
FROM table1 a, table2 b, table3 c 
WHERE a.sha256 = b.sha256 AND status = 3 or 2
GROUP BY a.sha256
LIMIT 0, 100

Anonymous,

Ještěže existují subselecty a lze s nimi získávat data dříve nevídaným způsobem.

SELECT count(*) WHERE    (select top 1 mo_osoba.ind_gastro FROM mo_osoba WITH (NOLOCK) WHERE mo_osoba.id_mo_osoba = 2606) = '1'

Anonymous,

Produkcni kod. A pak se divi, ze je to pomale...

-- Delete User Log
DECLARE @intIdentityLog   as Int
DECLARE curTrans CURSOR
LOCAL FORWARD_ONLY
FOR SELECT
       UserLog_intIdentity
FROM tblUser_Log
WHERE UserLog_dtmDateRec BETWEEN @DateToPurge AND @dtmRetainAfter

OPEN   curTrans
FETCH NEXT FROM curTrans
INTO   @intIdentityLog
WHILE  @@FETCH_STATUS = 0
BEGIN
       SET @Processed = 'Y'
       IF @intTestMode<> 'Y'
       BEGIN
             DELETE FROM tblUser_Log
             WHERE CURRENT OF curTrans
       END
       ELSE
       BEGIN
             PRINT 'ULOGI : ' + CAST (@intIdentityLog AS varchar(10))
       END

       FETCH NEXT FROM curTrans INTO @intIdentityLog
END

CLOSE curTrans
DEALLOCATE curTrans

Lukáš Navrátil,

Keď je databázový expert Rumun.

BEGIN 
 FOR r IN (SELECT * FROM Picture WHERE qr_frame_color IS NULL)
 LOOP
  UPDATE Picture SET qr_frame_color = '#ff0000' WHERE pic_id = r.pic_id
  COMMIT;
 END LOOP;
END;

Anonymous,

Aneb když se mi zdá, že málo vyhledávám.

SELECT village_part_description_id
FROM village_part_description_assignment
WHERE village_part_description_id = 78

Zbyněk Rybička,