sql - How to get query to work with Declare @Lookup table -


i need following code work, however, giving me error @ last select statement. error receiving is:

incorrect syntax near keyword 'select'.

could please assist in resolving issue? thank you.

declare @lookup table(     id int identity(1, 1)   , songtitle nvarchar(512) )  insert @lookup(songtitle) select * (     values('deuce')          , ('strutter')          , ('black_diamond')          , ('parasite')          , ('strange_ways')          , ('rock_bottom')          , ('god_of_thunder')          , ('love_gun')          , ('she')          , ('i_stole_your_love') )  select albums.albumname      , songs.songtitle       , songs.writers       , songs.vocals       , songs.sid       , songs.thetime albums inner join songs s      on a.aid = s.aid inner join @lookup l     on l.songtitle = s.songtitle order l.id 

you need provide alias derived tables

insert @lookup(songtitle) select * (     values('deuce')          , ('strutter')          , ('black_diamond')          , ('parasite')          , ('strange_ways')          , ('rock_bottom')          , ('god_of_thunder')          , ('love_gun')          , ('she')          , ('i_stole_your_love') ) v; -- <<< provide alias derived tables 

if assign alias table, use alias instead of table name.

select a.albumname -- <<< use alias instead of table name      , s.songtitle -- <<< use alias instead of table name       , s.writers       , s.vocals       , s.sid       , s.thetime albums inner join songs s      on a.aid = s.aid inner join @lookup l     on l.songtitle = s.songtitle order l.id; 

Comments

Popular posts from this blog

javascript - jQuery: Add class depending on URL in the best way -

caching - How to check if a url path exists in the service worker cache -

Redirect to a HTTPS version using .htaccess -