Note that there are some explanatory texts on larger screens.

plurals
  1. PODelete singular entries
    primarykey
    data
    text
    <p>If I have this table:</p> <pre><code>+------+-------+---------------+--------+-----------------+------------+-----------+----------------+------+------+--------+------------+------------+ | type | class | username | userid | userip | usermobile | useremail | daysleft| pin1 | pin2 | pin3 | active | schoolname | schoolsite | +------+-------+---------------+--------+-----------------+------------+-----------+----------------+------+------+--------+------------+------------+ | B | A | sebbetest | 1000 | 123.123.123.123 | none | none | 50| 0 | 0 | 0 | Y | none | none | | A | A | stackowerflow | 5355 | 123.123.123.123 | none | none | 50| 0 | 0 | 0 | Y | none | haha | | C | A | good | 4223 | 123.123.123.124 | none | none | 50| 0 | 0 | 0 | Y | none | haha | | A | A | tester | 6353 | 123.123.123.125 | none | none | 50| 0 | 0 | 0 | Y | none | haha | | B | A | admin | 3453 | 123.123.123.125 | none | none | 50| 0 | 0 | 0 | Y | none | eeee | | A | A | sebastian | 1342 | 123.123.123.126 | none | none | 50| 0 | 0 | 0 | Y | none | eeee | | C | A | username | 6456 | 123.123.123.125 | none | none | 50| 0 | 0 | 0 | Y | none | woooooow | +------+-------+---------------+--------+-----------------+------------+-----------+----------------+------+------+--------+------------+------------+ </code></pre> <p>As you see, the user "good" with the IP "123.123.123.124" AND user "sebastian" with IP "123.123.123.126" has no "companions", no other users on the same IP.</p> <p>The user "sebbetest" has a companion "stackowerflow".</p> <p>The user "tester" has 2 companions: "admin" and "username".</p> <p>Now I want to delete these users that lack companions. How I do? For atomic reasons and to prevent concurrent access from munging the database, I would want to delete all "non-companion" users in a single expression of SQL.</p> <p>I tried with: DELETE FROM lan WHERE COUNT(userip) = 1;</p> <p>got this: ERROR 1111 (HY000): Invalid use of group function</p> <p>No rows are duplicates. If there is a need to check if a entry is unique regardless of IP, (type, userid) is unique.</p> <p>In other words, if IP is unique in a row, delete it.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload