![]() ![]() The input of gurus will be highly appreciated – leave it in the comments below.Ĭan we do this in PHP? Yes, of course. This is certainly doable but if the requirement becomes more complicated in a larger table, it takes more time and is more error prone.Ĭan we do this with a single SQL statement? I am not an SQL expert and I haven’t been able to figure out how to achieve the desired result (“6 consecutive losses”) from one SQL statement. I get this “6 consecutive losses” by manually counting from the last played match all the way up (towards earlier games) and see how long an “L” (meaning a loss) in winlose column can appear. Well, I have to admit Lakers are not playing very well these days. ![]() (I am using MySQL Workbench as the GUI tool to manage my MySQL databases. The Lakers matches status table data (partial) for 2013-2014 season Some of the latest records showing Lakers’ 2013-14 season are shown below:įig 2. I have been updating this table since 2008. The Lakers matches status table structure The table structure behind it is straightforward:įig 1. My personal website has a page showing the scores of my favorite NBA team: LA Lakers. As mentioned above, we will also touch on some other stored procedure statements. It contains only four commands that are related to cursor declaration, opening, closing, and fetching. ![]() The official documentation on cursors is located here. Since a cursor is implemented in a stored procedure, it has all the benefits (and limitations) of an SP (access control, pre-compiled, hard to debug, etc). When such an operation on a record can also be done in the PHP layer, it saves data transfer amounts as we can just return the processed aggregation/statistical result back to the PHP layer (thus eliminating the select – foreach – manipulation process at the client side). With cursors, we can traverse a dataset and manipulate each record to accomplish certain tasks. I would be inclined to treat a cursor as a “pointer” in C/C++, or an iterator in PHP’s foreach statement. It is an essential component in stored procedures. A cursor can’t be used by itself in MySQL. ![]()
0 Comments
Leave a Reply. |
Details
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |