Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- mysql> DESC etouches_attendees;
- +----------------+--------------+------+-----+---------+-------+
- | FIELD | TYPE | NULL | KEY | DEFAULT | Extra |
- +----------------+--------------+------+-----+---------+-------+
- | attendeeid | INT(11) | NO | PRI | NULL | |
- | drupal_uid | INT(11) | NO | PRI | NULL | |
- | regstatus | VARCHAR(128) | YES | | | |
- | email | VARCHAR(64) | NO | MUL | NULL | |
- | name | VARCHAR(128) | YES | | | |
- | drupal_hash | VARCHAR(32) | YES | | | |
- | drupal_created | INT(11) | NO | | NULL | |
- | drupal_updated | INT(11) | NO | | NULL | |
- +----------------+--------------+------+-----+---------+-------+
- 8 ROWS IN SET (0.00 sec)
- mysql> DESC etouches_attendee_details;
- +------------+----------+------+-----+---------+-------+
- | FIELD | TYPE | NULL | KEY | DEFAULT | Extra |
- +------------+----------+------+-----+---------+-------+
- | attendeeid | INT(11) | NO | PRI | NULL | |
- | details | longtext | NO | | NULL | |
- +------------+----------+------+-----+---------+-------+
- 2 ROWS IN SET (0.00 sec)
- mysql> SELECT email, attendeeid FROM etouches_attendees WHERE email = 'zlu@me.com';
- +------------+------------+
- | email | attendeeid |
- +------------+------------+
- | zlu@me.com | 4 |
- | zlu@me.com | 1223 |
- +------------+------------+
- mysql> SELECT attendeeid FROM etouches_attendee_details WHERE attendeeid IN (4, 1223);
- +------------+
- | attendeeid |
- +------------+
- | 4 |
- | 1223 |
- +------------+
- Goal: DELETE the records WITH attendeeids LOWER than 1223 FROM BOTH TABLES:
- mysql> SELECT email, MAX(attendeeid) FROM etouches_attendees WHERE email IN(SELECT email FROM etouches_attendees GROUP BY email, email HAVING COUNT(1) > 1);+------------+-----------------+
- | email | MAX(attendeeid) |
- +------------+-----------------+
- | zlu@me.com | 1223 |
- +------------+-----------------+
- 1 ROW IN SET (0.18 sec)
- 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;
- Query OK, 0 ROWS affected (0.00 sec)
- FUCK A DUCK (0 ROWS affected)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement