wigga
July 1st, 2009, 06:24 PM
i must get the tracks in all playlists, than i must get the artist and album name... (AfLijsten means Playlist)
i have the following install:
use master;
go
if db_id('dbGuus') is not null drop database dbGuus;
go
create database dbGuus;
go
use dbGuus;
go
create table tblAlbums( alId int identity(1,1) primary key,
alNm varchar(16) not null,
constraint uAlbum unique (alNm));
go
create table tblArtists( arId int identity(1,1) primary key,
arNm varchar(16) not null);
go
create table tblTracks( trId int identity(1,1) primary key,
alId int not null references tblAlbums(alId),
trTitle varchar(16) not null,
trTime int not null,
arId int not null references tblArtists(arId),
trGenre varchar(16) not null,
trFile varchar(max) not null,
constraint uTrack unique (alId, trTitle));
go
create table tblAfLijsten( afId int identity(1,1) primary key,
afNm varchar(16) not null,
constraint uAfLijst unique (afNm));
go
create table tblAfTracks( afId int not null references tblAfLijsten(afId),
trId int not null references tblTracks(trId),
constraint pkAfTrack primary key (afId, trId));
go
than i try this query:
select tblTracks.trId, trTitle, tbllAlbums.alNm, tblArtists.arNm, trGenre, trTime, tblAfTracks.afId from tblAfTracks, tblTracks, tblArtists where tblTracks.trId=tblAfTracks.trId and tblArtists.arId=tblTracks.arId and tblAlbums.alId=tblTracks.alId
and get this error:
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "tblAlbums.alId" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "tbllAlbums.alNm" could not be bound.
i have the following install:
use master;
go
if db_id('dbGuus') is not null drop database dbGuus;
go
create database dbGuus;
go
use dbGuus;
go
create table tblAlbums( alId int identity(1,1) primary key,
alNm varchar(16) not null,
constraint uAlbum unique (alNm));
go
create table tblArtists( arId int identity(1,1) primary key,
arNm varchar(16) not null);
go
create table tblTracks( trId int identity(1,1) primary key,
alId int not null references tblAlbums(alId),
trTitle varchar(16) not null,
trTime int not null,
arId int not null references tblArtists(arId),
trGenre varchar(16) not null,
trFile varchar(max) not null,
constraint uTrack unique (alId, trTitle));
go
create table tblAfLijsten( afId int identity(1,1) primary key,
afNm varchar(16) not null,
constraint uAfLijst unique (afNm));
go
create table tblAfTracks( afId int not null references tblAfLijsten(afId),
trId int not null references tblTracks(trId),
constraint pkAfTrack primary key (afId, trId));
go
than i try this query:
select tblTracks.trId, trTitle, tbllAlbums.alNm, tblArtists.arNm, trGenre, trTime, tblAfTracks.afId from tblAfTracks, tblTracks, tblArtists where tblTracks.trId=tblAfTracks.trId and tblArtists.arId=tblTracks.arId and tblAlbums.alId=tblTracks.alId
and get this error:
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "tblAlbums.alId" could not be bound.
Msg 4104, Level 16, State 1, Line 1
The multi-part identifier "tbllAlbums.alNm" could not be bound.