Query statement to update a secondary page

I have a building table with a unique ID.  I would like to run a query and update the variables in the secondary table.
select "NOR", "SOU","EAS","WES" FROM 'BLD1" WHERE 'SEQ' = "NY100350012"
UPDATE SURVEY_SPACE SET (NOR = $NOR.................

Can't this be done in one statement?
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Which db tech is in use, question deals whether during the select you can as you illustrate assign one of the columns to a variable.

Select $NOR:="NOR".....

The other question is what is the application that does this update, seems.
The application should already have this information such that your update will include all requisite information.
breeze351Author Commented:
In the table "BLD1" the name is "SEQ".
In the table "BLD1" the name is "NOR".

In the table "Survey_Data" the name is "SEQ"
In the table "Survey_Data" the name is "NOR"

When I update "BLD1", I want to update "NOR" in all the records in "Survey_Data" with the same "SEQ" number.
Not clear what situation, usually, the record insertion...
Understanding your process..

Table stracture/definition.for both

On what basis, what is the where clause on whose basis the record being updated can be distinguished from all other records?
Why Diversity in Tech Matters

Kesha Williams, certified professional and software developer, explores the imbalance of diversity in the world of technology -- especially when it comes to hiring women. She showcases ways she's making a difference ithrough the Colors of STEM program.

Kyle AbrahamsSenior .Net DeveloperCommented:
in MS SQL Server you can do this with a join:

update sd
set sd.NOR = b.NOR
survey_data sd
join bld1 b on sd.SEQ = b.SEQ
where sd.Seq = @seq

Open in new window

Note that you can also do this from an update trigger so it happens automatically.

create trigger tr_BLD1_NOR
on dbo.bld1
after update
    if update(NOR)
             update sd
             set sd.NOR = i.NOR
             survey_data sd 
             join inserted i on sd.seq = i.seq

Open in new window

breeze351Author Commented:
Wouldn't this work?
if ($up_down == "U")
		$dst = "MT";
		$north = $_POST['Up_North'];	
		$south = $_POST['Up_South'];	
		$east = $_POST['Up_East'];	
		$west = $_POST['Up_West'];
		$dst = "DT";
		$north = $_POST['Down_North'];	
		$south = $_POST['Down_South'];	
		$east = $_POST['Down_East'];	
		$west = $_POST['Down_West'];
$SqlString = "UPDATE survey_data
		NOR = '$north',
		SOU = '$south',
		EAS = '$east',
		WES = '$west'
	    SEQ = '$Building_Id'";

Open in new window

Kyle AbrahamsSenior .Net DeveloperCommented:
You're calling it from the front end and it would require an extra trip to the database (I'm thinking that's PHP?)

If the logic is that it should be both values all the time it's better to do that in the database.

EG:  I run an update statement manually against the DB and break your logic.
breeze351Author Commented:
I've tried the following code:
$String = "UPDATE survey_data
    survey_data.NOR = bld1.NOR,
    survey_data.SOU = bld1.SOU,
    survey_data.EAS = bld1.EAS,
    survey_data.WES = bld1.WES	
    INNER JOIN ON survey_data = bld1
    survey_data.SEQ = bld1.SEQ";


Open in new window

When I try it in PHPMyadmid. it doesn't like the join statement.

The error is :
An expression was expected. (near "INNER JOIN" at position 139)
slightwv (䄆 Netminder) Commented:
I'm not a SQL Server person but syntax from the database I am familiar with, you need to specify the table name in the FROM.

You also need to specify the ON clause of the join syntax instaad of the WHERE.

A quick Google seems to support that.

Try using the syntax here:

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Update does not use from, it uses
Update tablename inner join table2 on tablename.survey_data=table2.bidl set tablename.column=

Your quert seems to equalize (copy existing data) from one table into another.

Usually, you need to compare columns not tables.
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.