Geeks Talk

Prepare for your Next Interview


Welcome to the Geeks Talk forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact us.

problem in select statement

This is a discussion on problem in select statement within the MY SQL forums, part of the Databases category; i want to retrieve data from two tables,but in single row i want these. suppose there r two tables,in which deptid are foreignkey,where deptid=10,i want one name from table,& where ...

Go Back   Geeks Talk > Databases > MY SQL
Register Blogs FAQ Tag Cloud Calendar Mark Forums Read
  #1 (permalink)  
Old 11-22-2007
Junior Member
 
Join Date: Aug 2007
Location: INDIA
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
ibrahim2006 is on a distinguished road
Smile problem in select statement

i want to retrieve data from two tables,but in single row i want these.
suppose there r two tables,in which deptid are foreignkey,where deptid=10,i want one name from table,& where deptid=20,I want another name,please verify this."urjent"
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 11-22-2007
Contributing Member
 
Join Date: Sep 2005
Posts: 53
Thanks: 3
Thanked 6 Times in 6 Posts
Beena is on a distinguished road
Re: problem in select statement

select a.column1, b. column2 from table1 a , table2 b whre a.depid = 20

you can include as many columns you want considering table1 as a , and table 2 as b.. just add the column names as in table...
Reply With Quote
  #3 (permalink)  
Old 11-23-2007
Expert Member
 
Join Date: Oct 2007
Location: Pune
Posts: 365
Thanks: 4
Thanked 61 Times in 50 Posts
bizzzzzare will become famous soon enough
Re: problem in select statement

I guess this should help

Select a.deptid, b.deptid, b.name from table1 a, table2 b
where a.deptid = b.deptid
and b.deptid = 20 or b.deptid = 10
Reply With Quote
  #4 (permalink)  
Old 05-20-2008
Junior Member
 
Join Date: Nov 2007
Location: United States
Posts: 4
Thanks: 0
Thanked 2 Times in 1 Post
teena_pappachan is on a distinguished road
Re: problem in select statement

select table1.name, table2.deptid
from table1, table2
where table2.deptid=10 and table2.deptid=20
Reply With Quote
Reply

  Geeks Talk > Databases > MY SQL

Thread Tools
Display Modes

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 On
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads

Thread Thread Starter Forum Replies Last Post
Can Select statement be used along with Update statement? pankit SQL 6 01-15-2009 06:19 AM
Is this a correct statement anoop4real C and C++ 13 05-22-2008 06:22 AM
Why we have to close connection, statement, prepared statement Geek_Guest Java 8 02-27-2008 06:09 AM
Select within select neeraj_sigh SQL 7 12-09-2007 03:59 AM
Evaluate SQL statement Geek_Guest Oracle 1 09-30-2007 06:04 AM


All times are GMT -4. The time now is 10:10 AM.


Powered by vBulletin® Version 3.8.4
Copyright ©2000 - 2010, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.3.1
Copyright © 2005 - 2010 GeekInterview.com. All Rights Reserved