Geeks Talk

Prepare for your Next Interview




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 ...


Go Back   Geeks Talk > Databases > MY SQL

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 11-22-2007
Junior Member
 
Join Date: Aug 2007
Location: INDIA
Posts: 1
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: Mumbai
Posts: 343
Thanks: 4
Thanked 49 Times in 41 Posts
bizzzzzare is on a distinguished road
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 0 Times in 0 Posts
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
Sponsored Links
Reply

  Geeks Talk > Databases > MY SQL


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
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
Can Select statement be used along with Update statement? pankit SQL 2 01-10-2008 05:30 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 04:25 PM.


Powered by vBulletin® Version 3.6.8
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.1.0
Copyright © 2008 GeekInterview.com. All Rights Reserved