SHARE
TWEET

Untitled

a guest Jan 15th, 2020 62 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
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top