[thelist] SQL Query Question

Jay Blanchard jay.blanchard at niicommunications.com
Mon Apr 15 14:04:01 CDT 2002


[snip]
> Can this be done?
>
> SELECT this, that, theother
> FROM tblFOO
> WHERE theother <> to a list of items from tblBAR

If you may not have sub-select capability, perhaps we can do a join instead,
throwing in a GROUP BY to remove repetition.

SELECT Min(tblFOO.this), Min(tblFOO.that), Min(tblFOO.theother)
FROM tblFOO
INNER JOIN tblBAR
      ON tblFOO.theother <> tblBAR.field
GROUP BY tblFOO.pk
[/snip]

--------------------------
|      tblFOO            |
--------------------------
| ID | Name | Phone      |
--------------------------
| 1  | John | 1115551212 |
| 2  | Jane | 2225551212 |
| 3  | Josh | 3335551212 |
| 4  | Joan | 4445551212 |
| 5  | Jake | 5555551212 |
--------------------------

--------------------------
|     tblBAR             |
--------------------------
| ID | ExemptPhone       |
--------------------------
| 1  | 1115551212        |
| 2  | 3335551212        |
--------------------------

When querying the two tables above we are looking to return;
--------------------------
| ID | Name | Phone      |
--------------------------
| 2  | Jane | 2225551212 |
| 4  | Joan | 4445551212 |
| 5  | Jake | 5555551212 |
--------------------------

for some reason that did not work, it returned all off the records in
tblFOO. I am trying outer joins right now to see if I can come up with a
solution. I must be having brain freeze as this looked to be a simple query
when it all was asked innocently enough....

Jay





More information about the thelist mailing list