SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Iron Speed
Go Back   ASP Free ForumsDatabaseSQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
Free Web 2.0 Code Generator! Generate data entry and reporting .NET Web apps in minutes. Quickly create visually stunning, feature-rich apps that are easy to customize and ready to deploy. Download Now!
  #1  
Old April 30th, 2008, 05:52 AM
chetan1 chetan1 is offline
Banned
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 10 chetan1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 23 sec
Warnings Level: 1
Reputation Power: 0
Joining of two tables

hi
I have site in php.I want to join two tables with left join.How possible.
One table comprises empid,deptt,empname etc.
second table consist city state country etc.
Plz solve this query.
thanks

Last edited by Shadow Wizard : May 9th, 2008 at 04:16 AM. Reason: removed signature

Reply With Quote
  #2  
Old April 30th, 2008, 08:34 AM
Wolffy's Avatar
Wolffy Wolffy is offline
Slaprentice of Wolves
Click here for more information.
 
Join Date: Aug 2007
Location: Mossville, IL
Posts: 1,015 Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 2 h 3 m 50 sec
Reputation Power: 329
Well, given the column names as you have in the post, you cant join these tables -- you need to have data that some how relates the the two tables. For example, given your two tables Employee and Address, you probably have a 1 to many (1-M) relationship between Employee and Address (I'm assuming a work address here). That is, each employee has only one work address but each address can have many employees. So, to make this 1-M relationship work, the Employee record must reference the primary key on the Address table (i.e a Foreign Key). The primary key (PK) on the Address table can be (and probably should be) an auto-number field.

So consider this structure
Code:
Employee Table
  EmpId    - Primary Key
  AddressId - Foreign Key
  Department
  EmpName
  etc.

Address Table
  AddressId  - Primary key
  city
  state
  etc.

SELECT whatever 
   FROM Employee E
   LEFT JOIN Address A
   ON (E.AddressId = A.AddressId)
__________________
Wolffy
------------------------
Teaching people to fish.

Reply With Quote
  #3  
Old May 1st, 2008, 02:40 AM
chetan1 chetan1 is offline
Banned
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 10 chetan1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 23 sec
Warnings Level: 1
Reputation Power: 0
Thanks buddy.Glad to get solution.I have one more question.
The Question is that I want to update two table with the help of store procedure thru id .
E.G.
I have list box in which empname and id is given.when i click on empname,all the relative data comes in textboxes from two tables.
After that i want to edit the data which present in textboxes and update that data thru update query.

Plz solve this......

Last edited by Shadow Wizard : May 9th, 2008 at 04:14 AM. Reason: removed signature

Reply With Quote
  #4  
Old May 1st, 2008, 08:10 AM
Wolffy's Avatar
Wolffy Wolffy is offline
Slaprentice of Wolves
Click here for more information.
 
Join Date: Aug 2007
Location: Mossville, IL
Posts: 1,015 Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level)Wolffy User rank is Major (30000 - 40000 Reputation Level) 
Time spent in forums: 1 Week 4 Days 2 h 3 m 50 sec
Reputation Power: 329
Fairly simple sproc. Because two tables are involved, you will need two update statements ; and because you have two update statements, you will need to use a BEGIN TRANSACTION and COMMIT TRANSACTION to ensure BOTH queries work. Give the spoc a go and if you get stuck, post what you have and we'll see if we can sort it.

Reply With Quote
  #5  
Old May 2nd, 2008, 05:18 AM
chetan1 chetan1 is offline
Banned
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2008
Posts: 10 chetan1 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 2 h 45 m 23 sec
Warnings Level: 1
Reputation Power: 0
this is store procedure:
CREATE PROCEDURE update_procedure
(
@updtid integer,
@namee char(10),

@organisation char(10),
@adrs char(16),
@area varchar(50),
@landline numeric(9),
@mob numeric(9),

@cty char(10),

@state char(10),
@contry char(10)
)
as
update name set namee=@namee,organisation=@organisation,adrs=@adrs ,area=@area,landline=@landline,mob=@mob where nameid=@updtid
declare @tempid integer
set @tempid=(select nameid from name)
print @tempid
update city set cty=@cty,state=@state,contry=@contry where ctyid=@updtid
GO
I have List box in which list of all organisations listed.when click on the organisation ,textfields filled with data according to the org. and ID.
I Store that id=@pdtid.
when i update ,all the organisation showed repeatedly can say 2 times.

Last edited by Shadow Wizard : May 9th, 2008 at 04:15 AM. Reason: removed signature

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseSQL Development > Joining of two tables


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 5 hosted by Hostway