LOS OUTER JOIN DE SQL SERVER
need to understand the post: have knowledge of SQL, although not necessarily in SQL Server (another thing that will be useful if you use it).
When one is accustomed to the behavior of a database engine specific, start with a different one can be a problem, since it is common to find individual cases where the behavior of both differ, especially when manage nulls.
In my case, I was accustomed to working with the Informix database IBM company, the most powerful and fast that I have used no doubt, when I started using / experiencing the Express version of SQL Server 2005 . I had to migrate an application from one language (4GL Dynamic ) to the new version improved sick ( Genero 4GL ) and a database to another.
All went well until I had to make a SQL with a "jar" OUTER JOIN.
The program in question, we needed to relate the products table with the table of stock, but we wanted to leave all the items that belong, for example, the family 'AJUSA', regardless of whether there was a corresponding record in the table of stock. In addition, for this example, we only see the year 2008.
The query to execute in Informix is \u200b\u200bvery simple: SELECT
article .* FROM existence .*
article, OUTER existence
WHERE articulo.fam_art = existencia.fam_art
AND article . cod_art = existencia.cod_art
AND articulo.fam_art = 'AJUSA'
AND existencia.ejercicio = 2008 ORDER BY
articulo.fam_art
To verify that the statement is correct, just do a SELECT COUNT of records in the table of items whose family is 'AJUSA' and compare the result of that consultation. Both statements return the same number of records. And if we have a few items we can make a comparison, I assure you that never fails.
However, if we do the equivalent query in SQL Server, it would be: SELECT
article .* FROM existence .*
existence RIGHT OUTER JOIN item ON
existencia.fam_art = article.
fam_art AND existencia.cod_art = Articulo.cod_art
WHERE articulo.fam_art = 'AJUSA' AND
existencia.ejercicio = 2008 ORDER BY articulo.fam_art
We will have a nasty surprise, as only return records that exist in both tables specified criteria, or what is, DOES A FUCKING INNER JOIN.
Digging around I found this page which was confirmed this statement and how to solve the problem. The way to work in SQL Server is a bit Especialito say the least: first filtering is done WHERE clause and AFTER! the OUTER JOIN.
The solution proposed in sqlteam website is to include the selection criteria in clause of ON OUTER JOIN . So that we understand, if we remove all items related to the stock table that are of 2008 (whether or not in this table), the necessary consultation would be: SELECT
article .* FROM
existence .* existence RIGHT OUTER JOIN item ON
existencia.fam_art = articulo.fam_art
AND existencia.cod_art = articulo.cod_art
AND existencia.ejercicio = 2008
But our case we have an additional problem, and we need only items whose family is 'AJUSA'. The field is part of fam_art OUTER JOIN , so that this condition be ignored by the search engine database, so that the query: SELECT
article .* FROM existence .*
existence RIGHT OUTER JOIN
article ON existencia.fam_art = articulo.fam_art
AND existencia.cod_art = articulo.cod_art
AND articulo.fam_art = 'AJUSA'
AND existencia.ejercicio = 2008
... give the same result as the previous SQL statement; come on, that takes all items whether or not they stock in 2008.
But the solution is close to taking the order of execution of the clauses, because what we do is use the ON clause to indicate the filters on the table that specifies the OUTER (in our case, ' "existence") and then use the WHERE clause for the table you want to extract all records ("article" in this example): SELECT
article .* FROM existence .*
existence RIGHT OUTER JOIN ON article
existencia.fam_art = articulo.fam_art
AND existencia.cod_art = articulo.cod_art
AND existencia.ejercicio = 2008 WHERE
articulo.fam_art = 'AJUSA'
This query returns the records we wanted to achieve.
The OUTER JOIN is used very rarely and is difficult to find information on this happy problem so I decided that as precious information had to be on this blog, which gets many visits, so that knowledge quickly spread XD .
Saturday, March 15, 2008
Sunday, March 2, 2008
Hot Topic Design Your Own Hoodie
VIVA CALIGULA (VERSIÓN OFFLINE)
frika Freaks and (let's put it in the plural, we optimistic), I had a little forgotten in my presentation about my contributions to this our blog (not yours, ours), and that is if there is something that I fell are the old video game (those who threw perfectly on a Pentium III or below) and free flash minigames, which is entirely devoted quite a few pages.
probably not soon take to bore you with my favorite games of those with less than gigahertz Rulan and need not occupy fucking 3 Gigabytes of hard disk to get them started towards the spectacular graphics and similar Memec, for it is always better buy a next-generation console to have to upgrade the computer every two years if we are delighted with the news of the recreational sector (being optimistic and talking about people with pasta, of course) and then for most of the time we feel cheated or disappointed with the playability of the product. I said, another day I'm bored with it XD.
Anyway, now I want to talk about a sick Flash jueguecillo fun and gore (as good) I found a couple of days in the fabulous Minijuegos web. It's "Viva Caligula" which embody the Roman emperor buzzed, he decides to eradicate the perversion of the streets of Rome ... killing all its citizens.
as tyrannical (rather than daunting) task, you can explore the seven hills of Rome and collect all the weapons that exist in the game, a total of 26, one for each letter of the alphabet represented on our keyboard (keep in mind that "Ñ "does not count for whites who designed the game).
citizens, those bastard pseudo-empathic, are just pissed off if you fill the streets with corpses or if they see you attack those who belong to the same group, so there will come a time when have to fight against everyone.
There is also a power that is activated when your character is drunk with power and thirst blood (wine, too) called "Rampage mode", allowing us to carve our victims with far less hits than usual.
Once all the weapons, you can enter the palace of our freak psychopath and BE PART OF AN ORGY! where you get to the pointer.
The game has been the result of collaboration between www.adultswim.com and www.popandco.com , whose websites have the possibility to play online with this and other great games like Bible Fight which can embody Moses, Eve, Satan, Jesus or even God himself to give the hosts against these and other biblical characters.
The downside of "Viva Caligula" is that it takes about 16 MB (6 MB master file and the rest for the textures that are charged to access the different levels). If you frequently delete temporary files from your browser, the burden of it can be a pain. That's why I did not stop until you get to download all the files that the game needs to function properly without Internet connection. Since I have not skipped any safety measures to do so and the game is free, here it is: Viva
Caligula (Offline)
File Password: elchicocostra.blogspot.com
rar file in the game and you have the Flash Player 9 (inside the folder "player") that allows you to enjoy the game more quickly than if you open it with your browser.
All Geek is a potential psychopath, so satisfy your baser instincts, fucking!
frika Freaks and (let's put it in the plural, we optimistic), I had a little forgotten in my presentation about my contributions to this our blog (not yours, ours), and that is if there is something that I fell are the old video game (those who threw perfectly on a Pentium III or below) and free flash minigames, which is entirely devoted quite a few pages.
probably not soon take to bore you with my favorite games of those with less than gigahertz Rulan and need not occupy fucking 3 Gigabytes of hard disk to get them started towards the spectacular graphics and similar Memec, for it is always better buy a next-generation console to have to upgrade the computer every two years if we are delighted with the news of the recreational sector (being optimistic and talking about people with pasta, of course) and then for most of the time we feel cheated or disappointed with the playability of the product. I said, another day I'm bored with it XD.
Anyway, now I want to talk about a sick Flash jueguecillo fun and gore (as good) I found a couple of days in the fabulous Minijuegos web. It's "Viva Caligula" which embody the Roman emperor buzzed, he decides to eradicate the perversion of the streets of Rome ... killing all its citizens.
as tyrannical (rather than daunting) task, you can explore the seven hills of Rome and collect all the weapons that exist in the game, a total of 26, one for each letter of the alphabet represented on our keyboard (keep in mind that "Ñ "does not count for whites who designed the game).
citizens, those bastard pseudo-empathic, are just pissed off if you fill the streets with corpses or if they see you attack those who belong to the same group, so there will come a time when have to fight against everyone.
There is also a power that is activated when your character is drunk with power and thirst blood (wine, too) called "Rampage mode", allowing us to carve our victims with far less hits than usual.
Once all the weapons, you can enter the palace of our freak psychopath and BE PART OF AN ORGY! where you get to the pointer.
The game has been the result of collaboration between www.adultswim.com and www.popandco.com , whose websites have the possibility to play online with this and other great games like Bible Fight which can embody Moses, Eve, Satan, Jesus or even God himself to give the hosts against these and other biblical characters.
The downside of "Viva Caligula" is that it takes about 16 MB (6 MB master file and the rest for the textures that are charged to access the different levels). If you frequently delete temporary files from your browser, the burden of it can be a pain. That's why I did not stop until you get to download all the files that the game needs to function properly without Internet connection. Since I have not skipped any safety measures to do so and the game is free, here it is: Viva
Caligula (Offline)
File Password: elchicocostra.blogspot.com
rar file in the game and you have the Flash Player 9 (inside the folder "player") that allows you to enjoy the game more quickly than if you open it with your browser.
All Geek is a potential psychopath, so satisfy your baser instincts, fucking!
Internet, where women are men, men are women and the kids are FBI agents
Subscribe to:
Comments (Atom)