post left outer join y el where
tengo una tabla t1 y una tabla t2
t1
c1
1
2
3
t2
c1 c2
1 1
2 1
3 1
entonces hago un T1 left outer join T2
on t2.c1 = t2.c1
and t2.c2 = 1
que creen que saldra?
bueno en el left outer join, hace las consultas para cada tabla
1ro para la t2, que trae todos los registros con c2 = 1
Luego procede a hacer el left y nos da
0 null null (no correspondio con ningun valor en T2)
1 1 1
2 2 1
3 3 1
Ahora que paso cuando cambias la condicion t2.c2 = 1, en el where
entonces hago un T1 left outer join T2
on t2.c1 = t2.c1
where t2.c2 = 1
como se puede decir, el left tiene mas prioridad que el where(osea este se realiza al ultimo)
1. realizandose priemro el left tendriamos
t1.c1 t2.c1 t2.c2
0 null null (no correspondio con ningun valor en T2)
1 1 1
2 2 1
3 3 1
2. Luego realizar el where t2.c2 =1, sobre lo anterior
t1.c1 t2.c1 t2.c2
1 1 1
2 2 1
3 3 1
Se filtro el registro que tenia t2.c2 = null, ya que la condicion en el where era t2.c2 = 1
Habra mas cosas sobre estas, espero sea todo, porque ese era uno de las cosas raras que no entendia, espero haberlo entendido bien y si no lo es, y sabes que hay algo mas oculto, hasmelo saber, te lo agradecere de alma =)
bye
Tuesday, July 08, 2008
Thursday, July 03, 2008
Getting ConnectionString in a package in runtime
I had a question, if i have to get the id country from a connection string, so i said yes, but i haven't done never, so i start to search in google, and in a few minutes i found the answer in this link.
So i create a simple package and start to prove, mi package look like this:
then, i add a script component
then, the code, re-very little =)
then, it works =)
thats all, read the link.
So i create a simple package and start to prove, mi package look like this:
then, i add a script component
then, the code, re-very little =)
then, it works =)
thats all, read the link.
@@ERROR in t-sql @_@
Well, i have a stored procedure that fail in some part, in a delete statement, but the sp continue running, and execute the next sp, something like that
CREATE PROC _SP_WRAP_ALLSP AS
EXEC SP1
EXEC SP2
.
.
.
Well, if a error ocurred in SP1, the _SP_WRAP_ALLSP continue with the next SP2,
then if you want to find a error, you have to use @@ERROR, like this link mentioned, and something else you get a code error, but what does it means? well sys.messages answer your question.
Bye
CREATE PROC _SP_WRAP_ALLSP AS
EXEC SP1
EXEC SP2
.
.
.
Well, if a error ocurred in SP1, the _SP_WRAP_ALLSP continue with the next SP2,
then if you want to find a error, you have to use @@ERROR, like this link mentioned, and something else you get a code error, but what does it means? well sys.messages answer your question.
Bye
Subscribe to:
Posts (Atom)