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
 Using Between Condition With Multiple Tables?

Author  Topic 

Palermo
Starting Member

25 Posts

Posted - 2010-12-29 : 20:40:11
Is it possible to use the between command to return data from multple tables? I have tables named :

England_Summer
England_Winter
France_Summer
France_Winter


SELECT*
FROM England_Summer
WHERE Fee BETWEEN '0.00' AND '20.00';


Returns values from the England_Summer table but how do I return the values from all the tables in the database?

SELECT*
FROM England_Summer, England_Winter
WHERE Fee BETWEEN '0.00' AND '20.00';


Gives this error :

Msg 208, Level 16, State 1, Line 1
Invalid object name 'England_Summer'.

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2010-12-29 : 20:47:50
That's saying there's no object England_Summer.
If they are the same structure why do you have 4 tables?
Maybe
select * from England_Summer WHERE Fee BETWEEN '0.00' AND '20.00'
union all
select * from England_Winter WHERE Fee BETWEEN '0.00' AND '20.00'



==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-01-04 : 12:51:07
First check if you've table called England_Summer available on same db

SELECT * FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_NAME = 'England_Summer'


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

MageshkumarM
Yak Posting Veteran

61 Posts

Posted - 2011-01-05 : 08:28:40
Can you pls look at the database name is correct and check there that table available or not..!


MAG,
Start with the new Idea..
Go to Top of Page
   

- Advertisement -