0
use temp1 select * from [TZraw].[dbo].[A1] where [TZraw].[dbo].[A1].[ID] in [select F1 from info1] 

I am trying to select all the records from TZraw table A1 that match every record in temp1 table F1

2
  • Is F1 the id ? All you have to do is return the ID from info1. select * from [TZraw].[dbo].[A1] where [TZraw].[dbo].[A1].[ID] in (select F1 as id from info1) Commented Feb 22, 2011 at 13:09
  • 1
    Have you checked the syntax for a join statement? Commented Feb 22, 2011 at 13:09

6 Answers 6

4

Use parenthesis:

select * from [TZraw].[dbo].[A1] where [TZraw].[dbo].[A1].[ID] in (select F1 from info1) 

Instead of square brackets on the subselect.

Sign up to request clarification or add additional context in comments.

Comments

3

Try round brackets for the subquery:

use temp1 select * from [TZraw].[dbo].[A1] where [TZraw].[dbo].[A1].[ID] in (select F1 from info1) 

Comments

3

You need parenthesis for the IN clause

select * from [TZraw].[dbo].[A1] where [TZraw].[dbo].[A1].[ID] in (select F1 from info1) 

Comments

1

try this in your query

... in (select F1 from info1) 

Comments

1

Your SQL syntax is incorrect - the subquery should be in parens - (), not square braces [].

Use a join instead of a subquery - SQL is better optimized for it:

SELECT first.* FROM [TZraw].[dbo].[A1] AS first INNER JOIN info1 AS second ON first.ID = second.F1 

Comments

0

Try to create a temporary table

Select * From Tzrav ti Where .... ti...<>t...

REATE TEMPORARY TABLE SalesSummary ( Select* From Temp1 t Where .... )

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.