<?xml version="1.0" encoding="utf-8"?>
<!-- generator="FeedCreator 1.7.2-ppt DokuWiki" -->
<?xml-stylesheet href="https://www.sqlines.com/lib/exe/css.php?s=feed" type="text/css"?>
<rdf:RDF
    xmlns="http://purl.org/rss/1.0/"
    xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#"
    xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
    xmlns:dc="http://purl.org/dc/elements/1.1/">
    <channel rdf:about="https://www.sqlines.com/feed.php">
        <title>SQLines Tools mysql:how-to</title>
        <description></description>
        <link>https://www.sqlines.com/</link>
        <image rdf:resource="https://www.sqlines.com/lib/images/favicon.ico" />
       <dc:date>2026-05-10T07:22:40+00:00</dc:date>
        <items>
            <rdf:Seq>
                <rdf:li rdf:resource="https://www.sqlines.com/mysql/how-to/get_top_n_each_group?rev=1323842443&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sqlines.com/mysql/how-to/join-different-tables-based-on-condition?rev=1324531743&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sqlines.com/mysql/how-to/select-rows-depending-on-previous-row?rev=1324134504&amp;do=diff"/>
                <rdf:li rdf:resource="https://www.sqlines.com/mysql/how-to/select-update-single-statement-race-condition?rev=1360669646&amp;do=diff"/>
            </rdf:Seq>
        </items>
    </channel>
    <image rdf:about="https://www.sqlines.com/lib/images/favicon.ico">
        <title>SQLines Tools</title>
        <link>https://www.sqlines.com/</link>
        <url>https://www.sqlines.com/lib/images/favicon.ico</url>
    </image>
    <item rdf:about="https://www.sqlines.com/mysql/how-to/get_top_n_each_group?rev=1323842443&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2011-12-14T06:00:43+00:00</dc:date>
        <title>MySQL - How To Get Top N Rows per Each Group</title>
        <link>https://www.sqlines.com/mysql/how-to/get_top_n_each_group?rev=1323842443&amp;do=diff</link>
        <description>Question: How to return the 2 largest cities for each country?

Sample Data


Assume we have the following table definition and data:


   CREATE TABLE cities
   (
      city VARCHAR(80),
      country VARCHAR(80),
      population INT
   );

   INSERT INTO cities VALUES ('New York', 'United States', 8175133); 
   INSERT INTO cities VALUES ('Los Angeles', 'United States', 3792621); 
   INSERT INTO cities VALUES ('Chicago', 'United States', 2695598); 

   INSERT INTO cities VALUES ('Paris', 'Fran…</description>
    </item>
    <item rdf:about="https://www.sqlines.com/mysql/how-to/join-different-tables-based-on-condition?rev=1324531743&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2011-12-22T05:29:03+00:00</dc:date>
        <title>MySQL - How to Join Different Tables Based on Condition (Switch Join - Select Tables on Condition)</title>
        <link>https://www.sqlines.com/mysql/how-to/join-different-tables-based-on-condition?rev=1324531743&amp;do=diff</link>
        <description>Sometimes in a single query, it is required to join different tables based on a condition in one of the tables. 

For example, you need to get all persons participating in a contest as individuals or as members of a team. Contest table points either to Team or Person table depending on the participant type:</description>
    </item>
    <item rdf:about="https://www.sqlines.com/mysql/how-to/select-rows-depending-on-previous-row?rev=1324134504&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2011-12-17T15:08:24+00:00</dc:date>
        <title>MySQL - How To Select Rows Depending on Value in Previous Row (Remove Duplicates in Each Sequence)</title>
        <link>https://www.sqlines.com/mysql/how-to/select-rows-depending-on-previous-row?rev=1324134504&amp;do=diff</link>
        <description>Question: There is a table that logs the customer support requests from different cities. How to get the list of cities in the order of requests from them. Note that the same city can be selected multiple times. 

For example, the log table content ( marks the rows that need to be selected by the query):</description>
    </item>
    <item rdf:about="https://www.sqlines.com/mysql/how-to/select-update-single-statement-race-condition?rev=1360669646&amp;do=diff">
        <dc:format>text/html</dc:format>
        <dc:date>2013-02-12T11:47:26+00:00</dc:date>
        <title>MySQL How To Select and Update in Single Statement - Increment Counter avoiding Race Condition</title>
        <link>https://www.sqlines.com/mysql/how-to/select-update-single-statement-race-condition?rev=1360669646&amp;do=diff</link>
        <description>Question: How to get the current value of the counter, and set the new value in the single SQL statement to avoid a race condition?

What is Race Condition?


Assume you a have a counter, and before you increment it, you need to get its current value.  This current value will be used as an ID for some operation, so concurrent sessions must not get the same value.</description>
    </item>
</rdf:RDF>
