Here’s the situation. I have two sets of data. One is a list of all the “ticket” entries that my system uses – at least one per ID, but potentially more. I also have a separate list of just the IDs that have known hardware problems, which is a relatively small (but important) subset of the IDs. I’ve put this list into a super-simple table B, which is literally a single column with just those IDs.
I need a MySQL query that joins these two tables, so I get all of the entries from table A, each of which has another field added on that is a simple boolean: whether or not the same ID exists in table B.
So something like this:
SELECT * FROM `table_A` A
LEFT JOIN `table_B` B ON A.id=B.id
If B were a two-column table, and the second column (call it down) was simply true in every row, then I could check if down were true or null.
But since B has only a single column, no data is actually added to the result.
Is there any simple way (without having this otherwise completely unnecessary column in my database) to do this “join” operation, that will simply note whether or not the ID of a given entry in A also exists in B?
(adding another field to A that is up or down is also rather inefficient, since there are often many rows for a single ID and most IDs aren’t going to be down anyway)
with the example below ‘down’ will not be null if the id exists in table_B