I’m trying to write an SQL query for my program, but I just can’t figure out how. I don’t know enough SQL.
I’m trying to implement an online team system (for some website). I have two tables:
teams | teamId, eventId
teammembers | teamId, userId, status
Now, I need to: delete all records in teammembers where the eventId for the corresponding teamId is 1.
I’m trying:
delete from teammembers where teamId=teams.teamId and teams.eventId=1;
I’m not sure if this is really doing what I’m trying to do.
Is this query wrong, and if it is (which probably is), how can I write such a query?
You don’t specify your RDBMS so here it is in MySQL