Link to home
Start Free TrialLog in
Avatar of pointeman
pointemanFlag for United States of America

asked on

Select Rows In Table Where Another Table Contains?

Seems like a simple query, but I'm not sure how to use only 'Exists'...

Select Domain,Computer,Log
 From Logs
 Where Exists (Select Alert From Alerts Where Alert = 1)
 
[Logs table]
Domain
Computer
Log

[Alerts table]
Domain
Computer
Alert

ASKER CERTIFIED SOLUTION
Avatar of JestersGrind
JestersGrind
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Avatar of Henrik Staun Poulsen
Henrik Staun Poulsen
Flag of Denmark image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I think my suggestion will compile to the same execution plan as the suggestion by JertersGrind
Avatar of pointeman

ASKER

No success with any code examples. This is the problem I'm having as well, I don't get it...
what is your required output from this query?

Dani
Alerts table has 2 = True and 30 = False
Log table has 500 entries

The return needs to be all Domain and Computer also listed in Alerts table where Alerts.Alert = 1 or True.

Kinda hard to explain...
My mistake they do work fine!