FishSword Posted March 5, 2011 Share Posted March 5, 2011 Hiya, I have a table that contains book purchase information for an online book shop. The database structure can be found below: Purchase_ID: Used as a unique identifier for the purchase Book_ID: Used to store the book that was purchased Customer_ID: Used to store the book purchaser Purchase_Date: Used to store the purchase date. Book_Selected: Define whether or not book is entered into competition. Upon clicking a link containing a particular "Purchase ID", how do I change the value of the "Book_Selected" field to "1", whilst changing the "Book_Selected" field values to "2" for any other Purchase ID's that have the same "Book ID". Cheers Quote Link to comment https://forums.phpfreaks.com/topic/229671-complex-mysql-query/ Share on other sites More sharing options...
fenway Posted March 5, 2011 Share Posted March 5, 2011 Don't store flags in the db. Quote Link to comment https://forums.phpfreaks.com/topic/229671-complex-mysql-query/#findComment-1183254 Share on other sites More sharing options...
FishSword Posted March 5, 2011 Author Share Posted March 5, 2011 Hi Fenway, thanks for your reply. What do you mean don't store flags in the db? Quote Link to comment https://forums.phpfreaks.com/topic/229671-complex-mysql-query/#findComment-1183257 Share on other sites More sharing options...
fenway Posted March 6, 2011 Share Posted March 6, 2011 I mean that if you query for "truth", instead of storing "state", there will be no book_selected field to update. Quote Link to comment https://forums.phpfreaks.com/topic/229671-complex-mysql-query/#findComment-1183512 Share on other sites More sharing options...
FishSword Posted March 6, 2011 Author Share Posted March 6, 2011 The problems is, how do I then know whether a book has been entered into the competition? Quote Link to comment https://forums.phpfreaks.com/topic/229671-complex-mysql-query/#findComment-1183518 Share on other sites More sharing options...
fenway Posted March 6, 2011 Share Posted March 6, 2011 Yet another table, with competition_id and book_id. Quote Link to comment https://forums.phpfreaks.com/topic/229671-complex-mysql-query/#findComment-1183547 Share on other sites More sharing options...
FishSword Posted March 8, 2011 Author Share Posted March 8, 2011 So are flags not good? - How come? I've looked at the database of forum software such as phpbb, mybb, and smf, and each stored flags such as pm_read = 0. Quote Link to comment https://forums.phpfreaks.com/topic/229671-complex-mysql-query/#findComment-1184727 Share on other sites More sharing options...
fenway Posted March 9, 2011 Share Posted March 9, 2011 Yeah, for optimizations afterwards. Quote Link to comment https://forums.phpfreaks.com/topic/229671-complex-mysql-query/#findComment-1184824 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.