INSERT INTO bm.events (title, image, start_date, end_date, text, payableWithCulturecard, reservation_id)  
SELECT name as title, thumb, startDate as start_date, endDate as end_date, "", 0, 1
  FROM old.bruckm_ticketevent WHERE reservationType = 'none' AND startDate != 0000-00-00 AND endDate != 0000-00-00;
  
  
  
  
INSERT IGNORE INTO bm.events (title, image, start_date, end_date, text, payableWithCulturecard, reservation_id)  
SELECT name as title, thumb, startDate as start_date, endDate as end_date, "", 0, 3
  FROM old.bruckm_ticketevent WHERE reservationType = 'seat' AND startDate != 0000-00-00 AND endDate != 0000-00-00;
  
UPDATE IGNORE bm.events SET 
    title=convert(cast(convert(title using  latin1) as binary) using utf8);
  
  
  INSERT IGNORE INTO bm.seats(date, event_id)
SELECT start_date, id
  FROM bm.events WHERE start_date > CURDATE() and reservation_id = 3;

UPDATE IGNORE bm.events SET 
    price_cat_a=10, price_cat_b = 15, price_cat_c = 20
    where price_cat_a is null;

  INSERT IGNORE INTO bm.event_concessions(event_id, concession_id)
SELECT id, 1
  FROM bm.events WHERE start_date > CURDATE() and reservation_id = 3;



-- start empore

 INSERT IGNORE INTO bm.single_seats (seat_id, booked, category, y,x) 
	SELECT  (
		select (
			select  (
				select (
					select (
						select id from bm.seats where event_id = test4.id limit 1
					)from bm.events as test4 where image like test3.thumb limit 1
				)  from old.bruckm_ticketevent as test3 where id = test2.eventId limit 1
			)  from old.bruckm_ticketdate as test2 where id = test1.dateId  limit 1
		)  from old.bruckm_ticket as test1 where dateId = myOuterTicket.dateId limit 1
    ),1,'a', seat+19, row+17 
    FROM old.bruckm_ticket as myOuterTicket
    where floor = "Empore" and row = 6;
    
    
    
    
    
 INSERT IGNORE INTO bm.single_seats (seat_id, booked, category, y,x) SELECT (
		select (
			select  (
				select (
					select (
						select id from bm.seats where event_id = test4.id limit 1
					)from bm.events as test4 where image like test3.thumb limit 1
				)  from old.bruckm_ticketevent as test3 where id = test2.eventId limit 1
			)  from old.bruckm_ticketdate as test2 where id = test1.dateId  limit 1
		)  from old.bruckm_ticket as test1 where dateId = myOuterTicket.dateId limit 1
    ),1,'a', IF(seat+13>17,seat+13+2, seat+13), row+17 FROM old.bruckm_ticket as myOuterTicket where floor = "Empore" and row = 5;
 
 
 INSERT IGNORE INTO bm.single_seats (seat_id, booked, category, y,x) SELECT (
		select (
			select  (
				select (
					select (
						select id from bm.seats where event_id = test4.id limit 1
					)from bm.events as test4 where image like test3.thumb limit 1
				)  from old.bruckm_ticketevent as test3 where id = test2.eventId limit 1
			)  from old.bruckm_ticketdate as test2 where id = test1.dateId  limit 1
		)  from old.bruckm_ticket as test1 where dateId = myOuterTicket.dateId limit 1
    ),1,'a', IF(seat+9>17,seat+9+2, seat+9) , row+17 FROM old.bruckm_ticket  as myOuterTicket where floor = "Empore" and row = 4;
 
 
 
 INSERT IGNORE INTO bm.single_seats (seat_id, booked, category, y,x) SELECT (
		select (
			select  (
				select (
					select (
						select id from bm.seats where event_id = test4.id limit 1
					)from bm.events as test4 where image like test3.thumb limit 1
				)  from old.bruckm_ticketevent as test3 where id = test2.eventId limit 1
			)  from old.bruckm_ticketdate as test2 where id = test1.dateId  limit 1
		)  from old.bruckm_ticket as test1 where dateId = myOuterTicket.dateId limit 1
    ),1,'a', IF(seat+5>17,seat+5+2, seat+5) , row+17 FROM old.bruckm_ticket  as myOuterTicket where  floor = "Empore" and row = 3;
 
 INSERT IGNORE INTO bm.single_seats (seat_id, booked, category, y,x) SELECT (
		select (
			select  (
				select (
					select (
						select id from bm.seats where event_id = test4.id limit 1
					)from bm.events as test4 where image like test3.thumb limit 1
				)  from old.bruckm_ticketevent as test3 where id = test2.eventId limit 1
			)  from old.bruckm_ticketdate as test2 where id = test1.dateId  limit 1
		)  from old.bruckm_ticket as test1 where dateId = myOuterTicket.dateId limit 1
    ),1,'a', IF(seat+2>17,seat+2+2, seat+2) , row+17 FROM old.bruckm_ticket as myOuterTicket where floor = "Empore" and row = 2;
 
 
 
 INSERT IGNORE INTO bm.single_seats (seat_id, booked, category, y,x) SELECT (
		select (
			select  (
				select (
					select (
						select id from bm.seats where event_id = test4.id limit 1
					)from bm.events as test4 where image like test3.thumb limit 1
				)  from old.bruckm_ticketevent as test3 where id = test2.eventId limit 1
			)  from old.bruckm_ticketdate as test2 where id = test1.dateId  limit 1
		)  from old.bruckm_ticket as test1 where dateId = myOuterTicket.dateId limit 1
    ),1,'a', IF(seat+3>17,seat+3+2, seat+3), row+17 FROM old.bruckm_ticket as myOuterTicket where floor = "Empore" and row = 1;
  

-- end empore


-- start first block (1-6)

  
  INSERT IGNORE INTO bm.single_seats (seat_id, booked, category, y,x) 
	SELECT  (
		select (
			select  (
				select (
					select (
						select id from bm.seats where event_id = test4.id limit 1
					)from bm.events as test4 where image like test3.thumb limit 1
				)  from old.bruckm_ticketevent as test3 where id = test2.eventId limit 1
			)  from old.bruckm_ticketdate as test2 where id = test1.dateId limit 1
		)  from old.bruckm_ticket as test1 where dateId = myOuterTicket.dateId limit 1
    ),1,'a', IF(seat>12,seat+1, seat), row 
    FROM old.bruckm_ticket as myOuterTicket
    where floor = "Erdgeschoss" and row <= 6;
-- end first block


-- start second block 
 INSERT IGNORE INTO bm.single_seats (seat_id, booked, category, y,x) 
	SELECT  (
		select (
			select  (
				select (
					select (
						select id from bm.seats where event_id = test4.id limit 1
					)from bm.events as test4 where image like test3.thumb limit 1
				)  from old.bruckm_ticketevent as test3 where id = test2.eventId limit 1
			)  from old.bruckm_ticketdate as test2 where id = test1.dateId  limit 1
		)  from old.bruckm_ticket as test1 where dateId = myOuterTicket.dateId limit 1
    ),1,'a', IF(seat>12,seat+1, seat), row+1 
    FROM old.bruckm_ticket as myOuterTicket
    where floor = "Erdgeschoss" and row >= 7 and row <= 8;
    
INSERT  IGNORE INTO bm.single_seats (seat_id, booked, category, y,x) 
	SELECT  (
		select (
			select  (
				select (
					select (
						select id from bm.seats where event_id = test4.id limit 1
					)from bm.events as test4 where image like test3.thumb limit 1
				)  from old.bruckm_ticketevent as test3 where id = test2.eventId limit 1
			)  from old.bruckm_ticketdate as test2 where id = test1.dateId  limit 1
		)  from old.bruckm_ticket as test1 where dateId = myOuterTicket.dateId limit 1
    ),1,'a', IF(seat+1>12,seat+1+1, seat+1), row+1 
    FROM old.bruckm_ticket as myOuterTicket
    where floor = "Erdgeschoss" and row = 9;
    
INSERT IGNORE INTO bm.single_seats (seat_id, booked, category, y,x) 
	SELECT  (
		select (
			select  (
				select (
					select (
						select id from bm.seats where event_id = test4.id limit 1
					)from bm.events as test4 where image like test3.thumb limit 1
				)  from old.bruckm_ticketevent as test3 where id = test2.eventId limit 1
			)  from old.bruckm_ticketdate as test2 where id = test1.dateId  limit 1
		)  from old.bruckm_ticket as test1 where dateId = myOuterTicket.dateId limit 1
    ),1,'a', IF(seat+2>12,seat+2+1, seat+2), row+1 
    FROM old.bruckm_ticket as myOuterTicket
    where floor = "Erdgeschoss" and row = 10;    
    
INSERT IGNORE INTO bm.single_seats (seat_id, booked, category, y,x) 
	SELECT  (
		select (
			select  (
				select (
					select (
						select id from bm.seats where event_id = test4.id limit 1
					)from bm.events as test4 where image like test3.thumb limit 1
				)  from old.bruckm_ticketevent as test3 where id = test2.eventId limit 1
			)  from old.bruckm_ticketdate as test2 where id = test1.dateId  limit 1
		)  from old.bruckm_ticket as test1 where dateId = myOuterTicket.dateId limit 1
    ),1,'a', IF(seat+5>12,seat+5+1, seat+5), row+1 
    FROM old.bruckm_ticket as myOuterTicket
    where floor = "Erdgeschoss" and row = 11;       
    
INSERT IGNORE INTO bm.single_seats (seat_id, booked, category, y,x) 
	SELECT  (
		select (
			select  (
				select (
					select (
						select id from bm.seats where event_id = test4.id limit 1
					)from bm.events as test4 where image like test3.thumb limit 1
				)  from old.bruckm_ticketevent as test3 where id = test2.eventId limit 1
			)  from old.bruckm_ticketdate as test2 where id = test1.dateId  limit 1
		)  from old.bruckm_ticket as test1 where dateId = myOuterTicket.dateId limit 1
    ),1,'a', IF(seat+8>12,seat+8+1, seat+8), row+1 
    FROM old.bruckm_ticket as myOuterTicket
    where floor = "Erdgeschoss" and row = 12;    
    
    
INSERT IGNORE INTO bm.single_seats (seat_id, booked, category, y,x) 
	SELECT  (
		select (
			select  (
				select (
					select (
						select id from bm.seats where event_id = test4.id limit 1
					)from bm.events as test4 where image like test3.thumb limit 1
				)  from old.bruckm_ticketevent as test3 where id = test2.eventId limit 1
			)  from old.bruckm_ticketdate as test2 where id = test1.dateId  limit 1
		)  from old.bruckm_ticket as test1 where dateId = myOuterTicket.dateId limit 1
    ),1,'a', IF(seat+12>12,seat+12+1, seat+12), row+1 
    FROM old.bruckm_ticket as myOuterTicket
    where floor = "Erdgeschoss" and row = 13;      
-- end second block

UPDATE old.bruckm_ticketcustomer
SET email=concat(firstname,".",surname,"@fakemail.at")
WHERE email = "";

INSERT IGNORE INTO bm.users (
	title, 
	firstname, 
    lastname, 
    street, 
    location, 
    phone, 
    admin, 
    email, 
    password, 
    resetPw)  
SELECT 
	acad as title, 
    firstname, 
    surname as lastname, 
    address as street, 
    concat(zip, city) as location, 
    phone, 
    0, 
    email, 
    "not yet setlusahgluhgugwhlahlglksghehgiuhghl",
    1
  FROM old.bruckm_ticketcustomer;
  
  
  
-- Förderer - wir für bruckmühle (8)
INSERT IGNORE INTO bm.user_usercategory (usercategory_id, user_id)  
SELECT 1, (select (select id from bm.users where email = old.email limit 1) from old.bruckm_ticketcustomer as old where id=a.customerId)
  FROM old.bruckm_ticketcustomergroupmemberships as a where groupId=32;

-- Galerie (185)
INSERT IGNORE INTO bm.user_usercategory (usercategory_id, user_id)  
SELECT 2, (select (select id from bm.users where email = old.email limit 1) from old.bruckm_ticketcustomer as old where id=a.customerId)
  FROM old.bruckm_ticketcustomergroupmemberships as a where groupId=4;

-- Mitglieder - wir für BM (70)
INSERT IGNORE INTO bm.user_usercategory (usercategory_id, user_id)  
SELECT 4, (select (select id from bm.users where email = old.email limit 1) from old.bruckm_ticketcustomer as old where id=a.customerId)
  FROM old.bruckm_ticketcustomergroupmemberships as a where groupId=34;

-- Stadtamt (126)
INSERT IGNORE INTO bm.user_usercategory (usercategory_id, user_id)  
SELECT 5, (select (select id from bm.users where email = old.email limit 1) from old.bruckm_ticketcustomer as old where id=a.customerId)
  FROM old.bruckm_ticketcustomergroupmemberships as a where groupId=21;

-- Kuka (292)
INSERT IGNORE INTO bm.user_usercategory (usercategory_id, user_id)  
SELECT 3, (select (select id from bm.users where email = old.email limit 1) from old.bruckm_ticketcustomer as old where id=a.customerId)
  FROM old.bruckm_ticketcustomergroupmemberships as a where groupId=8;

delete ignore from bm.users where email like "%fakemail.at";
UPDATE IGNORE bm.users SET 
    firstname=convert(cast(convert(firstname using  latin1) as binary) using utf8);

UPDATE IGNORE bm.users SET 
    lastname=convert(cast(convert(lastname using  latin1) as binary) using utf8);
update bm.events set price_cat_a=25, price_cat_b=19, price_cat_c=0 where start_date='2018-02-08';
update bm.events set price_cat_a=20, price_cat_b=0, price_cat_c=0 where start_date='2018-02-22';
update bm.events set price_cat_a=20, price_cat_b=16, price_cat_c=0 where start_date='2018-02-23';
update bm.events set price_cat_a=8, price_cat_b=0, price_cat_c=0 where start_date='2018-02-28';
update bm.events set price_cat_a=23, price_cat_b=18, price_cat_c=16 where start_date='2018-03-01';
update bm.events set price_cat_a=22, price_cat_b=17, price_cat_c=0 where start_date='2018-03-10';
update bm.events set price_cat_a=22, price_cat_b=17, price_cat_c=0 where start_date='2018-03-16';
update bm.events set price_cat_a=24, price_cat_b=19, price_cat_c=0 where start_date='2018-03-23';
update bm.events set price_cat_a=25, price_cat_b=20, price_cat_c=0 where start_date='2018-04-07';
update bm.events set price_cat_a=22, price_cat_b=17, price_cat_c=0 where start_date='2018-04-12';
update bm.events set price_cat_a=15, price_cat_b=0, price_cat_c=0 where start_date='2018-04-14';
update bm.events set price_cat_a=30, price_cat_b=25, price_cat_c=20 where start_date='2018-04-19';
update bm.events set price_cat_a=20, price_cat_b=16, price_cat_c=0 where start_date='2018-05-05';
update bm.events set price_cat_a=26, price_cat_b=21, price_cat_c=0 where start_date='2018-05-09';
update bm.events set price_cat_a=17, price_cat_b=13, price_cat_c=0 where start_date='2018-05-12';
update bm.events set price_cat_a=25, price_cat_b=22, price_cat_c=17 where start_date='2018-05-18';
update bm.events set price_cat_a=20, price_cat_b=17, price_cat_c=0 where start_date='2018-05-26';
update bm.events set price_cat_a=25, price_cat_b=20, price_cat_c=0 where start_date='2018-06-09';
update bm.events set price_cat_a=9, price_cat_b=0, price_cat_c=0 where start_date='2018-06-16';
update bm.events set price_cat_a=25, price_cat_b=20, price_cat_c=0 where start_date='2018-06-23';
update bm.events set price_cat_a=25, price_cat_b=20, price_cat_c=16 where start_date='2018-06-29';
update bm.events set price_cat_a=25, price_cat_b=20, price_cat_c=0 where start_date='2018-07-07';
-- start movesmall (3) seatmap
SET @myDate = "2018-03-23";

UPDATE bm.single_seats SET y=y+3 WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and x < 17);

UPDATE bm.single_seats SET y=y+1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and y > 13 and x < 17);

UPDATE bm.single_seats SET y=y-1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and y > 17 and x < 17);

SET @myDate = "2018-03-16";

UPDATE bm.single_seats SET y=y+3 WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and x < 17);

UPDATE bm.single_seats SET y=y+1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and y > 13 and x < 17);

UPDATE bm.single_seats SET y=y-1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and y >= 17  and x < 17);

SET @myDate = "2018-06-09";

UPDATE bm.single_seats SET y=y+3 WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and x < 17);

UPDATE bm.single_seats SET y=y+1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and y > 13 and x < 17);

UPDATE bm.single_seats SET y=y-1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and y >= 17  and x < 17);

SET @myDate = "2018-03-10";

UPDATE bm.single_seats SET y=y+3 WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and x < 17);

UPDATE bm.single_seats SET y=y+1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and y > 13 and x < 17);

UPDATE bm.single_seats SET y=y-1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and y >= 17  and x < 17);

SET @myDate = "2018-02-23";

UPDATE bm.single_seats SET y=y+3 WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and x < 17);

UPDATE bm.single_seats SET y=y+1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and y > 13 and x < 17);

UPDATE bm.single_seats SET y=y-1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and y >= 17  and x < 17);

SET @myDate = "2018-05-12";

UPDATE bm.single_seats SET y=y+3 WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and x < 17);

UPDATE bm.single_seats SET y=y+1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and y > 13 and x < 17);

UPDATE bm.single_seats SET y=y-1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and y >= 17  and x < 17);

SET @myDate = "2018-05-05";

UPDATE bm.single_seats SET y=y+3 WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and x < 17);

UPDATE bm.single_seats SET y=y+1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and y > 13 and x < 17);

UPDATE bm.single_seats SET y=y-1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and y >= 17  and x < 17);

SET @myDate = "2018-04-12";

UPDATE bm.single_seats SET y=y+3 WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and x < 17);

UPDATE bm.single_seats SET y=y+1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and y > 13 and x < 17);

UPDATE bm.single_seats SET y=y-1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and y >= 17  and x < 17);

UPDATE bm.single_seats SET y=y+1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and x >= 17);

SET @myDate = "2018-04-07";

UPDATE bm.single_seats SET y=y+3 WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and x < 17);

UPDATE bm.single_seats SET y=y+1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and y > 13 and x < 17);

UPDATE bm.single_seats SET y=y-1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and y >= 17  and x < 17);

-- end move small (3) seatmap
UPDATE bm.events as tmp1  SET text = (SELECT text FROM textbm.events WHERE id = tmp1.id)  WHERE (SELECT count(*) FROM textbm.events WHERE id = tmp1.id)  > 0;

UPDATE bm.events as tmp1  SET shorttext = (SELECT shorttext FROM textbm.events WHERE id = tmp1.id)  WHERE (SELECT count(*) FROM textbm.events WHERE id = tmp1.id)  > 0;
SET @myDate = "2018-02-22";

UPDATE bm.single_seats SET y=y+1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate);

SET @myDate = "2018-03-01";

UPDATE bm.single_seats SET y=y+1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate);

SET @myDate = "2018-04-19";

UPDATE bm.single_seats SET y=y+1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate);

SET @myDate = "2018-05-09";

UPDATE bm.single_seats SET y=y+1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate);


SET @myDate = "2018-05-18";

UPDATE bm.single_seats SET y=y+1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate);

SET @myDate = "2018-05-26";

UPDATE bm.single_seats SET y=y+3 WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and x < 17);

UPDATE bm.single_seats SET y=y+1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and y > 13 and x < 17);

UPDATE bm.single_seats SET y=y-1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate and y >= 17  and x < 17);

SET @myDate = "2018-06-23";

UPDATE bm.single_seats SET y=y+1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate);

SET @myDate = "2018-06-29";

UPDATE bm.single_seats SET y=y+1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate);

SET @myDate = "2018-07-06";

UPDATE bm.single_seats SET y=y+1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate);

SET @myDate = "2018-07-07";

UPDATE bm.single_seats SET y=y+1
WHERE seat_id=(SELECT (select id from bm.seats as test2 where event_id = test1.id limit 1) 
FROM bm.events as test1 where start_date like @myDate);
UPDATE `bm`.`single_seats` SET `y`='5' WHERE `id`='2186';
UPDATE bm.single_seats SET y=y+1 where seat_id=15 and x>17;
UPDATE bm.single_seats SET y=y+1 where seat_id=9 and x>17;
UPDATE bm.single_seats SET y=y+1 where seat_id=3 and x>17;
UPDATE `bm`.`single_seats` SET `y`='12' WHERE `id`='2103';
UPDATE bm.single_seats SET y=y-1 where seat_id=2 and x=10;
UPDATE `bm`.`single_seats` SET `y`='13' WHERE `id`='2019';
UPDATE bm.single_seats SET y=y-2 where seat_id=2 and x=12;
UPDATE `bm`.`single_seats` SET `y`='12' WHERE `id`='2261';
UPDATE bm.single_seats SET y=y-2 where seat_id=2 and x=13;
UPDATE `bm`.`single_seats` SET `y`='12' WHERE `id`='2320';
UPDATE bm.single_seats SET y=y-2 where seat_id=2 and x=14;
UPDATE `bm`.`single_seats` SET `y`='4' WHERE `id`='2102';
UPDATE `bm`.`single_seats` SET `y`='8' WHERE `id`='2293';
UPDATE `bm`.`single_seats` SET `y`='26' WHERE `id`='2081';
UPDATE `bm`.`single_seats` SET `y`='19' WHERE `id`='2163';
UPDATE `bm`.`single_seats` SET `y`='20' WHERE `id`='2164';
use bm;
update single_seats set y=y-1 where x > 17 and seat_id=15;
update single_seats set y=y+1 where x > 17 and seat_id=14;
update single_seats set y=y-1 where x > 17 and seat_id=9;
insert into single_seats (x,y,booked,seat_id,category) VALUES (1,13,1,7,'a');
insert into single_seats (x,y,booked,seat_id,category) VALUES (1,12,1,7,'a');
insert into single_seats (x,y,booked,seat_id,category) VALUES (1,15,1,7,'a');
insert into single_seats (x,y,booked,seat_id,category) VALUES (1,16,1,7,'a');
insert into single_seats (x,y,booked,seat_id,category) VALUES (1,17,1,7,'a');
insert into single_seats (x,y,booked,seat_id,category) VALUES (2,15,1,7,'a');
insert into single_seats (x,y,booked,seat_id,category) VALUES (2,16,1,7,'a');
update single_seats set y=y+1 where x > 17 and seat_id=12;
update single_seats set y=13 where seat_id=12 and x=10;
update single_seats set y=y+1 where x > 17 and seat_id=6;
UPDATE `bm`.`single_seats` SET `y`='10' WHERE `id`='1898';
insert into single_seats (x,y,booked,seat_id,category) VALUES (2,23,1,3,'a');
insert into single_seats (x,y,booked,seat_id,category) VALUES (2,24,1,3,'a');
UPDATE `bm`.`single_seats` SET `y`='13' WHERE `id`='1859';
UPDATE `bm`.`single_seats` SET `y`='12' WHERE `id`='1973';
UPDATE bm.events as tmp1  SET room = (SELECT room FROM textbm.events WHERE id = tmp1.id)  WHERE (SELECT count(*) FROM textbm.events WHERE id = tmp1.id)  > 0;
UPDATE bm.events as tmp1  SET starttime = (SELECT starttime FROM textbm.events WHERE id = tmp1.id)  WHERE (SELECT count(*) FROM textbm.events WHERE id = tmp1.id)  > 0;
