danielfpaiva 0 Posted October 22, 2017 Report Share Posted October 22, 2017 Boa Noite, Precisava da vossa ajuda porque não sei como conseguir obter o resultado que necessito. O problema é o seguinte: Existe uma tabela XPTO e uma tabela OPTX que está ligadas por um foreign key. Eu necessitava de obter os elementos da tabela XPTO que não se encontram na tabela OPTX. Será que alguém me pode ajudar? Link to post Share on other sites
Retsu9 13 Posted October 23, 2017 Report Share Posted October 23, 2017 Boas, Secalhar é mais fácil se mostrares a estrutura das tabelas e as ligações. Link to post Share on other sites
M6 150 Posted October 23, 2017 Report Share Posted October 23, 2017 Fazes um select * from XPTO where not exists (select 1 from OTPX where xpto.chave1 = otpx.chave1 and xpto.chave2 = otpx.chave2) Ou seja, vais buscar todos os registos da XPTO que não existam na chave de ligação entre ambas as tabelas. 1 Report 10 REM Generation 48K! 20 INPUT "URL:", A$ 30 IF A$(1 TO 4) = "HTTP" THEN PRINT "400 Bad Request": GOTO 50 40 PRINT "404 Not Found" 50 PRINT "./M6 @ Portugal a Programar." Link to post Share on other sites
danielfpaiva 0 Posted November 1, 2017 Author Report Share Posted November 1, 2017 Em 23/10/2017 às 09:50, M6 disse: Fazes um select * from XPTO where not exists (select 1 from OTPX where xpto.chave1 = otpx.chave1 and xpto.chave2 = otpx.chave2) Ou seja, vais buscar todos os registos da XPTO que não existam na chave de ligação entre ambas as tabelas. Obrigado pela ajuda Link to post Share on other sites
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now