insert into test2 (test_id, type)
select test.id, type_value from test1
join (
select 1 as type_value
union all
select 2
) as types ON TRUE -- нужно декартово произведение
where not exists (select 1 from test2 where test2.test_id = test.id)
select u.email, p.post_id, TIMESTAMPDIFF(DAY, p.publicated_to, now())
from users u
join posts p ON user_id =u.id
Waiting for table level lock
The time to acquire the initial locks is not counted as execution time.
Foreign keys not supported for partitioned InnoDB table
Note that mysqli_stmt_bind_param() requires parameters to be passed by reference, whereas call_user_func_array() can accept as a parameter a list of variables that can represent references or values.
select * from users where id not in (select user_id from user_roles join roles on role_id = roles.id where roles.title='админ')
select * from users where not exists (select user_id from user_roles join roles on role_id = roles.id where roles.title='админ' and user_id = users.id)
select * from users left join (user_roles, roles) ON (role_id = roles.id and user_id = users.id and roles.title='админ') where user_id is null