I want to use a JOIN to return a boolean result. Here's an example of the data...
t1
id | data
-----------
1 | abcd
2 | 2425
3 | xyz
t2
id | data | t1_id |
-------------------------
1 | 75 | 2 |
2 | 79 | 2 |
3 | 45 | 3 |
So with these two tables I want to select all the data from t1, and also whether a given variable appears in t2.data for each id.
So say the variable is 79, the results should be
id | data | t2_boolean
--------------------------
1 | abcd | 0
2 | abcd | 1
3 | xyz | 0
So I'm thinking some sort of join is needed, but without a WHERE clause. I've been banging my head about this one. Is it possible? I really need it inside the same statement as I want to sort results by the boolean field.
As the boolean needs to be a field, can I put a join inside of a field?
Thanks...