serg-52 (11/26/2015)
Luis Cazares (11/26/2015)
Be aware that the example doesn't represent a recursive query. That's just a query using union allYes, exactly. If OP needs more levels we need more info what are those levels about.
So sorry for the mystake... I just started and I gave you wrong subject.
Two questions about code 'union all':
1. If I would add other field to table film
film (
...
[commento] [nvarchar](50) NULL,
[voto] [int] NULL,
....
how should I modify statement to show them in output?
2.I should try to add a 2^ level of hierarchical (i.e. nodes under 1st level 'titolo n'): a table sub_film with a foreign key fk_film
CREATE TABLE [dbo].[sub_film](
[id_sub_film] [int] NOT NULL,
[sub_titolo] [varchar](50) NULL,
[fk_film] [int] NULL
INSERT INTO sub_film
VALUES
(1,'sub_titolo 2.0', 2),
(2,'sub_titolo 2.1', 2),
(2,'sub_titolo 3.0', 3),
My target is following output:
horror
| titolo 1
| titolo 2
| sub_titolo 2.0 (2nd level)
| sub_titolo 2.1 (2nd level)
fantascienza
| titolo 3
| sub_titolo 3.0 (2nd level)
I hope I explained in a proper way.
Thanks
Mara