You are here: Re: SQL question « MsSQL Server « IT news, forums, messages
Re: SQL question

Posted by ZeldorBlat on 07/07/07 19:22

On Jul 7, 2:59 pm, dwightarmyofchampi...@hotmail.com wrote:
> How do you combine two SELECT statements from two different tables
> into one result (assuming bioth tables have the exact same fields)?
>
> Like, assuming that the query SELECT * FROM Table1 gives the result
>
> ID Name
> 001 Smith
> 002 Jones
>
> and the query SELECT * FROM Table2 gives the result
>
> ID Name
> 247 Simpson
> 856 Beckley
>
> I want a SELECT ... ORDER BY ID statement that will output the
> following data:
>
> ID Name
> 001 Smith
> 002 Jones
> 247 Simpson
> 856 Beckley
>
> How do I do this?

select id, name
from table1
union
select id name
from table2
order by id

 

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

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