Ðàçðàáîòêà áàç äàííûõ â Delphi. 11 Óðîêîâ

       

 IN


Ïðåäèêàò IN ïðîâåðÿåò, âõîäèò ëè çàäàííîå çíà÷åíèå, ïðåäøåñòâóþùåå êëþ÷åâîìó ñëîâó “IN” (íàïðèìåð, çíà÷åíèå ñòîëáöà èëè ôóíêöèÿ îò íåãî) â óêàçàííûé â ñêîáêàõ ñïèñîê. Åñëè çàäàííîå ïðîâåðÿåìîå çíà÷åíèå ðàâíî êàêîìó-ëèáî ýëåìåíòó â ñïèñêå, òî ïðåäèêàò ïðèíèìàåò çíà÷åíèå true. Ðàçðåøåíî òàêæå èñïîëüçîâàòü êîíñòðóêöèþ  NOT  IN.

SELECT first_name, last_name, job_code

FROM employee

WHERE job_code IN ("VP", "Admin", "Finan")
                        ïîëó÷èòü ñïèñîê ñîòðóäíèêîâ,
                                                                  çàíèìàþùèõ äîëæíîñòè
                                                                  “âèöå-ïðåçèäåíò”, “àäìèíèñòðàòîð”,
                                                                  “ôèíàíñîâûé äèðåêòîð”

FIRST_NAME      LAST_NAME        JOB_CODE

=============== ================ ========

Robert          Nelson           VP      

Terri           Lee              Admin   

Stewart         Hall             Finan   



Ann             Bennet           Admin   

Sue Anne        O'Brien          Admin   

Mary S.         MacDonald        VP      

Kelly           Brown            Admin   

À âîò ïðèìåð çàïðîñà, èñïîëüçóþùåãî ïðåäèêàò  NOT  IN:

SELECT first_name, last_name, job_country

FROM employee

WHERE job_country NOT IN

      ("USA", "Japan", "England")
                       ïîëó÷èòü ñïèñîê ñîòðóäíèêîâ,
                                                                ðàáîòàþùèõ íå â ÑØÀ, íå â ßïîíèè
                                                                è íå â Âåëèêîáðèòàíèè

FIRST_NAME      LAST_NAME        JOB_COUNTRY    

=============== ================ ===============

Claudia         Sutherland       Canada         

Roberto         Ferrari          Italy          

Jacques         Glon             France         

Pierre          Osborne          Switzerland



Ñîäåðæàíèå ðàçäåëà