 INTO OUTFILE '/tmp/label.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '"' LINES TERMINATED BY '\n';
 
 -- RESTAURANT INFO
-SELECT id+200000000, `name`, `url`, `lat`, `lng`, `address`, `num_smile`, `num_ok`, `num_not_ok` FROM restaurant
-WHERE EXISTS (
-	SELECT 1 FROM bi_restaurant
-	WHERE bi_restaurant.id=restaurant.id
-)
+SELECT restaurant.id+200000000, `name`, `url`, `lat`, `lng`, `address`, `num_smile`, `num_ok`, `num_not_ok` FROM restaurant
+-- WHERE EXISTS (
+-- 	SELECT 1 FROM bi_restaurant
+-- 	WHERE bi_restaurant.id=restaurant.id
+-- )
+INNER JOIN bi_restaurant ON bi_restaurant.id=restaurant.id
 INTO OUTFILE '/tmp/restaurant.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '"' LINES TERMINATED BY '\n';
 
 -- USER INFO
-SELECT id+300000000,name FROM user
-WHERE EXISTS (
-	SELECT 1 FROM bi_user
-	WHERE bi_user.id=user.id
-)
+SELECT user.id+300000000,name FROM user
+-- WHERE EXISTS (
+-- 	SELECT 1 FROM bi_user
+-- 	WHERE bi_user.id=user.id
+-- )
+INNER JOIN bi_user ON bi_user.id=user.id
 INTO OUTFILE '/tmp/user.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '"' LINES TERMINATED BY '\n';
 
 

FROM label_restaurant
INNER JOIN restaurant ON restaurant_id=restaurant.id
INNER JOIN label ON label_id=label.id
WHERE EXISTS (
	SELECT 1 FROM bi_restaurant
	WHERE bi_restaurant.id=restaurant_id
)
INTO OUTFILE '/tmp/label_restaurant.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '"' LINES TERMINATED BY '\n';

-- USER - RESTAURANT
SELECT user_id+300000000,restaurant_id+200000000,type FROM rating_implicit
WHERE EXISTS (
	SELECT 1 FROM bi_restaurant
	WHERE bi_restaurant.id=restaurant_id
)
INTO OUTFILE '/tmp/rating_bookmark.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '"' LINES TERMINATED BY '\n';

-- USER - USER

FROM user_love
INNER JOIN user ON user_id=user.id
INNER JOIN label ON label_id=label.id
-- WHERE EXISTS (
-- 	SELECT 1 FROM bi_user
-- 	WHERE bi_user.id=user_id
-- )
INNER JOIN bi_user ON bi_user.id=user_id
INTO OUTFILE '/tmp/user_love.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '"' LINES TERMINATED BY '\n';

-- USER - RESTAURANT
