Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 update with inner join and where claus
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

peace
Constraint Violating Yak Guru

420 Posts

Posted - 03/23/2012 :  00:28:26  Show Profile  Reply with Quote
How can i update with inner join and where claus?

want to update passenger table to update the exact country.
As in the View table I cant update.

View passenger table:
ID Name PNumber Country
1 Jane 12345 JP


Passenger table:
ID Name PNumber
1 Jane 12345

COuntry table:
ID Country
1U US

Contact table:
ID Name Pnumber
1 Jane 1234

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 03/23/2012 :  00:40:21  Show Profile  Reply with Quote
howzz country table related to other tables?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

peace
Constraint Violating Yak Guru

420 Posts

Posted - 03/23/2012 :  00:44:01  Show Profile  Reply with Quote
In my View table there is Country

View passenger table:
ID Name PNumber Country
1 Jane 12345 JP

But i cannot update View table
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 03/23/2012 :  00:47:49  Show Profile  Reply with Quote
so does JP correspond to ID field in Country table?

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

peace
Constraint Violating Yak Guru

420 Posts

Posted - 03/23/2012 :  00:56:14  Show Profile  Reply with Quote
If i select will be like this :

SELECT A.Id,
C.emailaddress1,
C.firstname,
[Country].Aa_shortcode

FROM A

INNER JOIN B
ON C.Id = B.Id

LEFT JOIN countryDetails[Country]
ON [Country].countryId = B.addresscountryid

WHERE emailaddress1 in ('abc@c.com')
Go to Top of Page

peace
Constraint Violating Yak Guru

420 Posts

Posted - 03/23/2012 :  01:00:56  Show Profile  Reply with Quote
Would like to update this guest country ('abc@c.com')

From JP to US
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 03/23/2012 :  01:21:19  Show Profile  Reply with Quote
your explanation doesnt make any sense. post proper data and explain your problem...otherwise we wont be able to help...

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

sarathy
Starting Member

India
2 Posts

Posted - 03/23/2012 :  11:54:07  Show Profile  Reply with Quote
Hi
Used this query for Inner join with using where condition, you get answer



select * from table 1 NF inner join table2 NP on nf.ID=np.ID inner join table3 NC on nf.ID= NC.ID where NF.Pnumbaer=12345

S.Partahasarthy
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52326 Posts

Posted - 03/23/2012 :  19:56:52  Show Profile  Reply with Quote
wont work as per posted data as ID value is not same in Country table

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.3 seconds. Powered By: Snitz Forums 2000