T-SQL Query: Select a row in one table based on data in another table

tcianflone
tcianflone used Ask the Experts™
on
I have two related tables, template and templine. They both have a template field that contains the template name and that's how they relate to each other. I need to select records in templine based on a field that appears only in template. Something like this:

select * from templine where template.type='M'

I don't know how to express template.type (which is supposed to find the type field in the template table) properly so that the query will run. Thanks.
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
Try with an SQL JOIN query;

SELECT *
FROM templine JOIN template
ON templine.name = template.name
WHERE template.type = 'M'

Author

Commented:
Thanks!

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial