rmeeuwsen Posted December 8, 2008 Share Posted December 8, 2008 I have two tables who both contain a field songwriter. 1 table is for a top 100 listing and the other is for songwriters. Songwriters may or may not occur in the top 100 table. How can I define a query that gives me all the songwriters that do not occur in the top 100 table? Thanks in advance! Robin Meeuwsen Quote Link to comment https://forums.phpfreaks.com/topic/136034-query-for-non-existance/ Share on other sites More sharing options...
dropfaith Posted December 8, 2008 Share Posted December 8, 2008 i would add a field in the songwriters table called top and have the value either be true or false 1 or 0 whatever you choose as values then just do a basic select of all the users in table where fieldname = false Quote Link to comment https://forums.phpfreaks.com/topic/136034-query-for-non-existance/#findComment-709269 Share on other sites More sharing options...
rmeeuwsen Posted December 8, 2008 Author Share Posted December 8, 2008 I could do that but I really would like to leave out the field from the songwriters table. Can it be done? Kind regards, Robin Meeuwsen Quote Link to comment https://forums.phpfreaks.com/topic/136034-query-for-non-existance/#findComment-709287 Share on other sites More sharing options...
rmeeuwsen Posted December 8, 2008 Author Share Posted December 8, 2008 OK. Another approach: 3 tables, tbl_projects ----------------- project_id name tbl_employees --------------------- employee_id name tbl_x ------- x_id project_id employee_id An employee can be working on several projects and a project can be worked by several employees. To create these relationships I created tbl_x which stores a record for every relationship. Now what I want to generate a list with all employees that are not working on any project. Thanks in advance! Robin Meeuwsen Quote Link to comment https://forums.phpfreaks.com/topic/136034-query-for-non-existance/#findComment-709317 Share on other sites More sharing options...
dropfaith Posted December 8, 2008 Share Posted December 8, 2008 set project id as 0 if no project is valid.. same approach i listed really would work with that format.. Quote Link to comment https://forums.phpfreaks.com/topic/136034-query-for-non-existance/#findComment-709759 Share on other sites More sharing options...
fenway Posted December 8, 2008 Share Posted December 8, 2008 set project id as 0 if no project is valid.. same approach i listed really would work with that format.. Zero? Why not use NULL as intended? Quote Link to comment https://forums.phpfreaks.com/topic/136034-query-for-non-existance/#findComment-709815 Share on other sites More sharing options...
prcollin Posted December 9, 2008 Share Posted December 9, 2008 i am assuming caues 0 is a defined value that you can use to create a function. Probably wrong but, thats my two cents Quote Link to comment https://forums.phpfreaks.com/topic/136034-query-for-non-existance/#findComment-710715 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.