Guest User

Untitled

a guest
Jan 15th, 2020
69
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. CREATE DEFINER=`root`@`localhost` PROCEDURE `make_friend`(
  2.     IN user1 BIGINT unsigned,
  3.     IN user2 BIGINT unsigned
  4. )
  5. BEGIN
  6.     INSERT INTO `friends` (`user1`, `user2`)
  7.     VALUES (user1, user2)
  8.     WHERE NOT EXISTS (
  9.         SELECT * FROM `friends` f
  10.         WHERE f.user1 NOT IN (user1,user2)
  11.         AND f.user2 NOT IN (user1,user2)
  12.     )
  13. END
RAW Paste Data