Information générale
Catégorie:
Codage, syntaxe et commandes
Titre:
Merge two tables in one on one rows!!!
Hi every body, Is it possible to merge two tables in one with only one SELECT-SQL? The first table is the parent and the second is the children. I want the select SQL return me the result on one row per parent!!!
Example:
table constructors (parent) table drivers (children)
NAME_CONST (fields) NAME_CONST, NAME_DRIVER
---------- ---------- -----------
Ferrari Ferrari Michael Schumacher
Williams Ferrari Rubbens Barrichello
Bar Williams Ralph Schumacher
Renault Williams Juan Pablo Montoya
Bar Jacques Villeneuve
The number of childrens can be different for each parent, i don't know the maximum of childrens, and the minimun can be zero!!!
I would like the result of the SQL select seem like that:
NAME_CONST NAME_DRIVER1 NAME_DRIVER2
---------- ------------ ------------
Bar Jacques Villeneuve (NULL)
Ferrari Michael Schumacher Rubben Barrichello
Renault (NULL) (NULL)
Williams Ralph Schumacher Juan Pablo Montoya
I works with Sql Server 2000!!!
Thanks!!!
Suivant
Répondre
Voir le fil de ce thread
Voir le fil de ce thread à partir de ce message seulement
Voir tous les messages de ce thread
Voir tous les messages de ce thread à partir de ce message seulement