You are here: Re: SELECT * FROM "multiple_tables" WHERE "field_(in_those_tables)_have_the_same_paricular_value" ? « MsSQL Server « IT news, forums, messages
Re: SELECT * FROM "multiple_tables" WHERE "field_(in_those_tables)_have_the_same_paricular_value" ?

Posted by andro on 04/24/06 01:46

Hugo !

Thank you very much for your help.
(I've noticed that such a simple question is not so simple to resolve with
basic SQL knowledge such as mine).
It is difficult to use first approach by entering everytime TBL_NAME (system
here).

Is there any easier way - by using table names as "parameters"?

I like your second approach.
Would you be more specific about "extra column (***part of the primary
key***)"
What do you mean by "part of the primary key"?

Thank you.


"Hugo Kornelis" <hugo@perFact.REMOVETHIS.info.INVALID> wrote in message
news:f9vn42dk7imst58vcv9f15ot3e7s30sh1j@4ax.com...
> On Mon, 24 Apr 2006 00:04:40 +0200, andro wrote:
>
>>Hi everybody!
>>
>>I have several tables from which I want to exract the SAME value (along
>>with
>>other referenced data).
>>All the values are in the same column within the tables.
>>How can I achieve this?
>>
>>TIA.
>>Andro
>>
>>
>>*************************
>>example: (piping bill of material where tables represent piping systems)
>>
>>TBL1-water
>>pos. item type size rating
>>---------------------------------
>>01 flange 3" 300#
>>02 valve wafer 2" 150#
>>03 valve ball 1" 150#
>>04 elr90 2"
>>
>>TBL2-oil
>>(similar like above).........etc.
>>----------------------------------
>>
>>how to select (say) BALL VALVES from these tables along with pos.,size,
>>rating etc.?
>>
>
> Hi Andro,
>
> SELECT 'water' AS system, pos, item, type, size, rating
> FROM TBL1_water
> WHERE type = 'ball'
> UNION ALL
> SELECT 'oil' AS system, pos, item, type, size, rating
> FROM TBL2_oil
> WHERE type = 'ball'
> UNION ALL
> etc
>
> But a better solution would be to use just one table, with water/oil/etc
> as extra column (part of the primary key), instead of splitting the data
> over several similar tables.
>
> --
> Hugo Kornelis, SQL Server MVP

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация