Connecting Tech Pros Worldwide Help | Site Map
Reply
 
LinkBack Thread Tools Search this Thread
  #1  
Old August 14th, 2008, 05:45 AM
Newbie
 
Join Date: Aug 2008
Posts: 1
Default How to Write this SQL Statement?

Hi,

Table A
Col1 Col2 Col3 Col4

Table B
Col5

Both tables are not linked to each other.

Table 5 have Values (10, 17, 30) Only.

Query
I am currently executing query in the following way
Select Col1, Col2, Col3, Col4, 10 From TableA where Col4 = '2008-08-10';
Select Col1, Col2, Col3, Col4, 17 From TableA where Col4 = '2008-08-10';
Select Col1, Col2, Col3, Col4, 30 From TableA where Col4 = '2008-08-10';

I want to make one query so that I dont have run this statement thrice.

If I use union then have to change these dates and other conditions three times.

Select Col1, Col2, Col3, Col4, 10 From TableA where Col4 = '2008-08-10'
Union
Select Col1, Col2, Col3, Col4, 17 From TableA where Col4 = '2008-08-10'
Union
Select Col1, Col2, Col3, Col4, 30 From TableA where Col4 = '2008-08-10'

Is there a way I can get one SQL Statement which does the work which this statement isw doing (UNION ONE). Just tot avoid changing conditions every where.

Thanks
Rohit
Reply
Reply

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over 204,687 network members.
Post your question now . . .
It's fast and it's free

Popular Articles