简体   繁体   中英

Invalid object name SQL select

I'm trying to select items from two tables which share the same unique identifier. The select statment I am using is;'

select 
f1.[filmTitle],
f1.[filmImagePath],
f1.[filmRating],
f1.[filmPrice],
f2.[filmActors],
f2.[filmDesciption],
f2.[filmTrailer],
f2.[filmLength],
f2.[filmDirector],
f2.[filmCertificate] 
FROM film.[filmID] f1 
JOIN filmData.filmID f2 
ON f1.filmID = f2.filmID 
WHERE (f1.filmID = @ID)

Table 1 [named 'films'] has the columns; filmID, filmTitle, filmImagePath, filmRating, filmPrice.

Table 2 [named 'filmData'] has the columns; filmID,filmActors,filmDesciption, filmTrailer, filmLength, filmDirector, filmCertificate.

I get the error "Invalid object name 'films.filmID'."

Thanks

Your table is called films . That is what you should be selecting from.

This:

FROM film.[filmID] f1 
JOIN filmData.filmID f2 

Should be this:

FROM films f1 
JOIN filmData f2 

What you're doing in your query is attempting to select a column from other columns.. which doesn't really make sense.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM