ifm1989 Posted November 9, 2007 Share Posted November 9, 2007 I know little about the join function of mysql, and the official manual just confuses me- I dont know what kind of join to use. I have table 1. For simplicity, lets say the columns are: Bonus ID | Bonus Name I have table 2. For simplicity, lets say the columns are: User ID | Bonus ID I need two queries: 1) Pulls all of the data in table1. If it finds a matching row in table 2, then the corresponding row in bonus gets set to true. If not, then set to false. 2) Pulls ONLY the data in table1 IF it finds a matching row in table 2. Then, the corresponding row in bonus gets set to true. If not, then set to false. Sample: Table1 1 Pie 2 Foo 3 bar Table 2 1 1 1 2 2 1 For method 1, if userid = 1, then: 1 Pie true 2 Foo true 3 bar false For method 2, if userid = 1, then: 1 Pie true 2 Foo true I hope I'm making this easy to understand. My english isnt very good, and my skill with mysql is worse :/ Quote Link to comment Share on other sites More sharing options...
Barand Posted November 9, 2007 Share Posted November 9, 2007 I don't understand the need for the 2 queries. The outcome is the same in both - something (undefined) gets set true or false. In the second, if it only pulls matching records, how do you hope to update those not matched, as they are excluded? Also you call them "table1" and "table2" for the sake of simplicity, yet you say a (undefined) column in "bonus" gets set to true or false. So is the "bonus" table "table1" or "table2", or something you haven't even mentioned? Quote Link to comment 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.