After doing a lot of searching and reading I think I came up empty on a subselect I wanted to do in MySQL. Here’s what I was trying to do:
tabel1
id rec
1 record 1
2 record 2
table2
t1id rec
1 val1
1 val2
2 val1
This is what I was trying to accomplish:
SELECT * FROM table1 WHERE id IN (SELECT * FROM table2 WHERE rec = val1);
I know there’s a million ways around this, with the correct 2 table syntax, a RIGHT JOIN, etc., but I was in this predicament where I just wanted to add to the original full select of SELECT * FROM table1.
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Mar | ||||||
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | |||
RSS feed for comments on this post · TrackBack URI
Leave a reply