I have two tables in an SQL Server 2008 R2 database, lets call them A and B. They look like this
A
--------------------
GUID Primary Key
B_GUID Foreign Key
Value nvarchar(50)
B
--------------------
GUID Primary Key
Value nvarchar(50)
I want to select all rows from A
where
B
Value
in BHowever, I can't figure out the SQL. Any help? :) Thanks
How about:
SELECT A.*
FROM dbo.A
INNER JOIN dbo.B ON A.B_GUID = B.GUID
WHERE
A.Value <> B.Value
The INNER JOIN matches the two tables together, on equality of those two columns, and the WHERE clause restricts it further to just two rows where that condition applies.
select
A.*
from
A
join
B on A.B_GUID = B.GUID and A.Value <> B.Value
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With