Hi, I need a sql query to join multiple lines into only one line. Ok, I wouldnīt understand this question so Iīll give an example (Iīm doing it on mysql but I need it to mssql). Supose I have 3 tables:
mysql> select * from test1; +----+-------+ | id | nome | +----+-------+ | 1 | Bruno | | 2 | Jorge | +----+-------+ mysql> select * from test2; +----+---------+-----------+ | id | request | value | +----+---------+-----------+ | 1 | 1 | 100,00 | | 1 | 2 | Mercedes | | 2 | 1 | 50,00 | | 2 | 3 | Sparc Sun | +----+---------+-----------+ mysql> select * from test3; +----+----------+ | id | value | +----+----------+ | 1 | money | | 2 | car | | 3 | computer | +----+----------+ test1.id -> test2.id test3.id -> test2.request When I execute: select test1.nome, test3.value, test2.value from test1, test2, test3 where test1.id = test2.id AND test2.request = test3.id I get: +-------+----------+-----------+ | nome | value | value | +-------+----------+-----------+ | Bruno | money | 100,00 | | Bruno | car | Mercedes | | Jorge | money | 50,00 | | Jorge | computer | Sparc Sun | +-------+----------+-----------+ But I need this result: +-------+----------+-----------+------------+ | nome | money | car | computer | +-------+----------+-----------+------------+ | Bruno | 100,00 | Mercedes | NULL | | Jorge | 50,00 | NULL | Sparc Sun | +-------+----------+-----------+------------+ Is it possible in Microsoft SQL Server? Iīd like to know if it can be executed on mysql and, if not, if there is some way to do it in mysql. Sorry for the big e-mail but itīs something I really need to know. Thankīs Bruno Gimenes Pereti. -- PHP Database Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php