tubar
11-24-2009, 05:06 PM
i have two tables linked in a query...one table is title the other is actor...i want to see what titles dont have actors but all i am getting are records that have both....how do i accomplish this
|
View Full Version : 2 table query with null tubar 11-24-2009, 05:06 PM i have two tables linked in a query...one table is title the other is actor...i want to see what titles dont have actors but all i am getting are records that have both....how do i accomplish this ajetrumpet 11-24-2009, 05:12 PM i am guessing something likie:SELECT table.title, table2.actor INNER JOIN etc... WHERE [actor] IS NULL tubar 11-24-2009, 05:28 PM better yet what would i do to build a query or code to go through all my id records in a table and list ones that are missing jal 11-25-2009, 02:26 AM i have two tables linked in a query...one table is title the other is actor...i want to see what titles dont have actors but all i am getting are records that have both....how do i accomplish this AjeTrumpet gave you the general outline, but I'll fill in some of the details. He's referring to to this type of query. SELECT * FROM Titles LEFT JOIN Actors ON Titles.TitleID = Actors.TitleID WHERE Actors.TitleID IS NULL The above is difficult to understand if you're an absolute beginner. You can rewrite this query in a way easier to understand (but it runs slow this way). SELECT TitleID FROM Titles WHERE TitleID NOT IN (SELECT TitleID FROM Actors) In both cases, this should report those titles that exist in the Titles table but do not exist in the Actors table (titles without actors). Or if you want those actors without titles: SELECT TitleID FROM Actors WHERE TitleID NOT IN (SELECT TitleID FROM Titles) |