Advertisement
Guest User

Untitled

a guest
Aug 12th, 2017
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
SQL 2.46 KB | None | 0 0
  1. mysql> DESC etouches_attendees;
  2. +----------------+--------------+------+-----+---------+-------+
  3. | FIELD          | TYPE         | NULL | KEY | DEFAULT | Extra |
  4. +----------------+--------------+------+-----+---------+-------+
  5. | attendeeid     | INT(11)      | NO   | PRI | NULL    |       |
  6. | drupal_uid     | INT(11)      | NO   | PRI | NULL    |       |
  7. | regstatus      | VARCHAR(128) | YES  |     |         |       |
  8. | email          | VARCHAR(64)  | NO   | MUL | NULL    |       |
  9. | name           | VARCHAR(128) | YES  |     |         |       |
  10. | drupal_hash    | VARCHAR(32)  | YES  |     |         |       |
  11. | drupal_created | INT(11)      | NO   |     | NULL    |       |
  12. | drupal_updated | INT(11)      | NO   |     | NULL    |       |
  13. +----------------+--------------+------+-----+---------+-------+
  14. 8 ROWS IN SET (0.00 sec)
  15.  
  16. mysql> DESC etouches_attendee_details;
  17. +------------+----------+------+-----+---------+-------+
  18. | FIELD      | TYPE     | NULL | KEY | DEFAULT | Extra |
  19. +------------+----------+------+-----+---------+-------+
  20. | attendeeid | INT(11)  | NO   | PRI | NULL    |       |
  21. | details    | longtext | NO   |     | NULL    |       |
  22. +------------+----------+------+-----+---------+-------+
  23. 2 ROWS IN SET (0.00 sec)
  24.  
  25. mysql> SELECT email, attendeeid  FROM etouches_attendees WHERE email = 'zlu@me.com';
  26. +------------+------------+
  27. | email      | attendeeid |
  28. +------------+------------+
  29. | zlu@me.com |          4 |
  30. | zlu@me.com |       1223 |
  31. +------------+------------+
  32.  
  33.  
  34. mysql> SELECT attendeeid FROM etouches_attendee_details WHERE attendeeid IN (4, 1223);
  35. +------------+
  36. | attendeeid |
  37. +------------+
  38. |          4 |
  39. |       1223 |
  40. +------------+
  41.  
  42. Goal: DELETE the records WITH attendeeids LOWER than 1223 FROM BOTH TABLES:
  43.  
  44.  
  45. mysql> SELECT email, MAX(attendeeid) FROM etouches_attendees WHERE email IN(SELECT email FROM etouches_attendees GROUP BY email, email HAVING COUNT(1) > 1);+------------+-----------------+
  46. | email      | MAX(attendeeid) |
  47. +------------+-----------------+
  48. | zlu@me.com |            1223 |
  49. +------------+-----------------+
  50. 1 ROW IN SET (0.18 sec)
  51.  
  52.  
  53.  
  54. mysql> DELETE FROM etouches_attendees, etouches_attendee_details USING etouches_attendees LEFT JOIN etouches_attendee_details ON etouches_attendees.attendeeid = etouches_attendee_details.attendeeid WHERE etouches_attendees.email = 'zlu@me.org' AND etouches_attendees.attendeeid < 1223;
  55. Query OK, 0 ROWS affected (0.00 sec)
  56.  
  57.  
  58. FUCK A DUCK (0 ROWS affected)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement