Help with database query. - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Using CodeIgniter (https://forum.codeigniter.com/forumdisplay.php?fid=5) +--- Forum: General Help (https://forum.codeigniter.com/forumdisplay.php?fid=24) +--- Thread: Help with database query. (/showthread.php?tid=61535) |
Help with database query. - T3utonicT3rror - 04-23-2015 Hey guys, For some reason today I just can't seem to think. I am currently working on part of my Forums solution, and I am working on the 'delete comment' function. Now where my problem lies is in the 'discussions' table I store the 'last_comment_id'. When you bring up the front page of the forums ( with all the discussions listed ) it says 'Last comment by {username}'. Now on to my question. Lets say I have 10 comments for that discussion, and just for example sake the ID's of them comments are 1 through to 10. I want to delete 10, what i need to do is grab the comment ID before 10 ( so 9 ) for this discussion. How would I go about doing this? As I said I know its a really daft question but my brain has turned into mush and I just can't seem to think straight. Any help would be appreciated guys. Chris RE: Help with database query. - Rufnex - 04-23-2015 You can do something like that (with mysql). PHP Code: delete from comments where id = 10 RE: Help with database query. - T3utonicT3rror - 04-23-2015 (04-23-2015, 05:03 AM)Rufnex Wrote: You can do something like that (with mysql). Haha i knew I was over thinking this! It was the query that I could not think of. Thats great mate thank you very much for the swift reply =) |