Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Assistance with a Query

Author  Topic 

ryan.cook
Starting Member

2 Posts

Posted - 2013-06-17 : 09:38:39
Hey, all;

I'm a bit new to SQL, but it's frequently used where I work. I've been delving a bit deeper into queries and ran into trouble with one.

What I'd like to do is:
-Find all rows in a table that have a specific value in a specific column.
-When a row is found, use the data from a different column to search another table

I apologize if that's somewhat vague. In the end, the goal is to search through a table, stop when a condition is met, then search another table with a specific column's data.

Thanks in advance!
Ryan

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-06-17 : 09:44:25
it will like this


SELECT t2.*
FROM SecondTable t2
INNER JOIN FirstTable t1
ON t1.col2 = t2.col2
WHERE t1.SearchColumn = 'your value'


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page

ryan.cook
Starting Member

2 Posts

Posted - 2013-06-17 : 10:06:13
Woo! Thank you, Visakh! I'll start fiddling around with that now :)
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-06-17 : 10:06:52
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -