Geeks Talk

Prepare for your Next Interview




SQL query

This is a discussion on SQL query within the SQL forums, part of the Databases category; Hi All, Need a help to solve the query, infact i am actually beginner to SQL. Two tables one with Emp and other Address table. They look similiar to like ...


Go Back   Geeks Talk > Databases > SQL

Register FAQ Members List Calendar Mark Forums Read
  #1 (permalink)  
Old 07-26-2008
Contributing Member
 
Join Date: Apr 2007
Location: Bangalore
Posts: 44
Thanks: 6
Thanked 7 Times in 6 Posts
prakash.kudrekar is on a distinguished road
SQL query

Hi All,

Need a help to solve the query, infact i am actually beginner to SQL.

Two tables one with Emp and other Address table. They look similiar to like this

Emp has two rows

Empid Ename

12 Scott
13 Tiger
14 Eagle


Address has two rows

Empid Add

12 Boston
13 Arizona
14 Boston

I need to list all the empid and ename whose address are same.


Thanks
regards
Prakash
Reply With Quote
The Following User Says Thank You to prakash.kudrekar For This Useful Post:
Sponsored Links
  #2 (permalink)  
Old 07-26-2008
Expert Member
 
Join Date: Sep 2007
Posts: 754
Thanks: 22
Thanked 64 Times in 63 Posts
krishnaindia2007 is on a distinguished road
Re: SQL query

Quote:
Originally Posted by prakash.kudrekar View Post
Hi All,

Need a help to solve the query, infact i am actually beginner to SQL.

Two tables one with Emp and other Address table. They look similiar to like this

Emp has two rows

Empid Ename

12 Scott
13 Tiger
14 Eagle


Address has two rows

Empid Add

12 Boston
13 Arizona
14 Boston

I need to list all the empid and ename whose address are same.


Thanks
regards
Prakash
Emp has two rows

Empid Ename

12 Scott
13 Tiger
14 Eagle

Here empid and ename are columns
In Emp table you have three rows and two columns.


The query is

Select a.empid, a.ename,b.add from emp a, address b
where a.empid = b.empid
Reply With Quote
  #3 (permalink)  
Old 07-30-2008
Junior Member
 
Join Date: Jul 2008
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
aleemkh is on a distinguished road
Re: SQL query

I need to insert around 40000 rows into table. Is there any simple way for this? like using some for loop or while loop?
Reply With Quote
  #4 (permalink)  
Old 07-30-2008
Contributing Member
 
Join Date: Apr 2007
Location: Bangalore
Posts: 44
Thanks: 6
Thanked 7 Times in 6 Posts
prakash.kudrekar is on a distinguished road
Angry Re: SQL query

Quote:
Originally Posted by krishnaindia2007 View Post
Emp has two rows

Empid Ename

12 Scott
13 Tiger
14 Eagle

Here empid and ename are columns
In Emp table you have three rows and two columns.


The query is

Select a.empid, a.ename,b.add from emp a, address b
where a.empid = b.empid

Dude this query would print all the rows since all employee ids wud be present in address table aganist to emp table
Reply With Quote
  #5 (permalink)  
Old 07-30-2008
Expert Member
 
Join Date: Sep 2007
Posts: 754
Thanks: 22
Thanked 64 Times in 63 Posts
krishnaindia2007 is on a distinguished road
Re: SQL query

Quote:
Originally Posted by prakash.kudrekar View Post
Dude this query would print all the rows since all employee ids wud be present in address table aganist to emp table
Just add one more line to the query given by me

and b.add in ( Here write query to return address having count(add)>1)

Last edited by krishnaindia2007 : 07-30-2008 at 10:04 AM.
Reply With Quote
  #6 (permalink)  
Old 07-30-2008
Expert Member
 
Join Date: Sep 2007
Posts: 754
Thanks: 22
Thanked 64 Times in 63 Posts
krishnaindia2007 is on a distinguished road
Re: SQL query

Quote:
Originally Posted by aleemkh View Post
I need to insert around 40000 rows into table. Is there any simple way for this? like using some for loop or while loop?

From where you are getting these 40000 rows?
Reply With Quote
Reply

  Geeks Talk > Databases > SQL


Thread Tools
Display Modes


Similar Threads

Thread Thread Starter Forum Replies Last Post
sql query help kothojubhaskar SQL 3 09-13-2008 02:53 AM
How to get this o/p from the sql query bhaski SQL 4 06-21-2008 02:27 AM
SQL query.. prafulkr SQL 2 02-14-2008 06:14 AM
sql query help... psuresh1982 SQL 6 07-23-2007 01:55 AM
regarding sql query psuresh1982 SQL 8 07-13-2007 04:20 AM


All times are GMT -4. The time now is 07:26 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