Hash join: Difference between revisions
Content added Content deleted
(Changed the whole SQL solution to illustrate better practices. Original solution was missing the key ingredient, the optimizer hint.) |
(Added Prolog) |
||
Line 2,374: | Line 2,374: | ||
28 : Alan : Ghosts |
28 : Alan : Ghosts |
||
28 : Alan : Zombies</pre> |
28 : Alan : Zombies</pre> |
||
=={{header|Prolog}}== |
|||
<lang Prolog>% Name/Age |
|||
person_age('Jonah', 27). |
|||
person_age('Alan', 18). |
|||
person_age('Glory', 28). |
|||
person_age('Popeye', 18). |
|||
person_age('Alan', 28). |
|||
% Character/Nemesis |
|||
character_nemisis('Jonah', 'Whales'). |
|||
character_nemisis('Jonah', 'Spiders'). |
|||
character_nemisis('Alan', 'Ghosts'). |
|||
character_nemisis('Alan', 'Zombies'). |
|||
character_nemisis('Glory', 'Buffy'). |
|||
join_and_print :- |
|||
format('Age\tName\tCharacter\tNemisis\n\n'), |
|||
forall( |
|||
(person_age(Person, Age), character_nemisis(Person, Nemesis)), |
|||
format('~w\t~w\t~w\t\t~w\n', [Age, Person, Person, Nemesis]) |
|||
).</lang> |
|||
{{out}} |
|||
<pre> |
|||
?- join_and_print. |
|||
Age Name Character Nemisis |
|||
27 Jonah Jonah Whales |
|||
27 Jonah Jonah Spiders |
|||
18 Alan Alan Ghosts |
|||
18 Alan Alan Zombies |
|||
28 Glory Glory Buffy |
|||
28 Alan Alan Ghosts |
|||
28 Alan Alan Zombies |
|||
true. |
|||
</pre> |
|||
=={{header|PureBasic}}== |
=={{header|PureBasic}}== |