Skip to content
Advertisement

Select row by user_id and any row which share that entry’s event_id

I have a table which includes the following format:

I considered storing users as JSON:

But I imagine this would be awful on performance when trying to look up an event based on a JSON value.

I want to be able to look up any events where a username appears, and return all rows which have the same event_id. Is this possible to do in a single query (as I wish to minimize server strain), or should I just do a nested select?

Advertisement

Answer

Decided to just do a nested select that returns event_id; I initially did not do this as I thought the multiple statement queries option of node-mysql needed to be enabled for it, but it turns out that is not the case.

User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement