Mysql one-to-many association, table An activity table, form B registration table, need to show all the activities that the current user does not participate in.

A Table
a_id
title

B Table
b_id
a_id
user_id
baomin

Table An is the active table, and Table B is the registration form
current user user_id equals 7

the requirement is to show all the activities that the current user has not signed up for and how to write the mysql statement, gods.

Apr.04,2021

explain only concepts
select from a left join b on where b_id is null

or
select from a where a_id not in (select a_id from b)


SELECT a.* FROM a 
WHERE NOT EXISTS(SELECT b.ID from b where a. a_id = b.a_id AND b. user_id = 7)

try this

through a subquery
-sharp table_aAtable_bB
SELECT a_id 'ID', title '' FROM table_a WHERE  a_id NOT IN (SELECT a_id FROM table_b WHERE user_id = 7);
MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1e49a5f-43300.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1e49a5f-43300.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?