SELECT statement

This is a discussion on "SELECT statement" within the Databases section. This forum, and the thread "SELECT statement are both part of the Program Your Website category.



 Subscribe in a reader

Go Back   Webforumz.com > Main Forums > Program Your Website > Databases

Notices


Reply
 
LinkBack Thread Tools
  #1  
Old Jan 27th, 2006, 17:38
Junior Member
Join Date: May 2005
Location: Virginia US
Age: 31
Posts: 26
Thanks: 0
Thanked 0 Times in 0 Posts
SELECT statement

I am trying to assign a field value [say column_B] from another table [say table_B] to a column name [say column_A] that is part of the query result set of table_A.

See example below.

SELECT A.Product, A.Customer, A.Vendor, ProductManager = (SELECT B.user_desc FROM TABLE B WHERE user_name = 'gecastill'), A.LaunchDate FROM TABLE A

How can I do that? I used to know how to do that but I have not done it in a year.

Please advise, thanks

Last edited by gecastill; Jan 27th, 2006 at 17:45.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote

  #2  
Old Feb 15th, 2006, 23:27
Up'n'Coming Member
Join Date: Feb 2004
Location: Woodbridge, UK
Age: 27
Posts: 80
Thanks: 0
Thanked 0 Times in 0 Posts
Lightbulb Re: SELECT statement

You pretty much just did it didn't you?

Code: Select all
 
SELECT
 Column1,
 Column2,
 [Column3] = (SELECT Column3 FROM table2 WHERE x=y),
 Column4
FROM dbo.table1
WHERE x=y
Would be better to see if you can acheive it with a join instead though...

Code: Select all
 
SELECT Column1,
 Column2,
 [Column3] b.Column3,
 Column4
FROM dbo.table1 As A
 LEFT OUTER JOIN dbo.table2 As B
  ON B.x = ?
WHERE x=y

Last edited by Trebz; Feb 15th, 2006 at 23:29.
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!Spurl this Post!Reddit! Wong this Post!
Reply With Quote
Reply

Tags
select, statement

Thread Tools

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 On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
chained select box dependable select thenamenoonehastaken JavaScript Forum 0 Feb 8th, 2008 05:49
PHP If Statement... mcdanielnc89 PHP Forum 16 Dec 9th, 2007 17:44
If..Else statement help IanW PHP Forum 3 Oct 6th, 2006 13:40
Select statement inside a rs loop? deeem Classic ASP 0 Sep 9th, 2006 15:42
With Statement Trebz Classic ASP 2 Feb 2nd, 2004 14:56


All times are GMT. The time now is 10:01.


Powered by vBulletin®
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.2.0 RC8
© 2003-2008 Webforumz.com : All Rights Reserved

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42