Link to home
Start Free TrialLog in
Avatar of thenone
thenone

asked on

sql update

How would I write a sql statement that will look for one field from one table and match it to the same filed in another field.If found it will update an integer number in the second table.The value of the integer will be represented by a text box in my form.
SOLUTION
Avatar of aikimark
aikimark
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of thenone
thenone

ASKER

would this update all of the fields at once?
Aikimark: I think he wants to update the SECOND table.

Brian
Avatar of thenone

ASKER

layout is like this

Table 1                       Table2
field1                          field1   id


update table2 "id" where table1 field1 matches table2 filed1 and use number from text field in vb.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Brian,

That is not correct.  You have a typo.  It should be
dim strSQL as string
strSQL = "update [table2] inner join [table 1] on [table 1].[field1] = [table2].[field1] set [ID] = " & me.text1.text

ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of thenone

ASKER

I am using mysql 5.0
Please be aware that a field named "ID" is likely to be a primary key, which might prohibit you from changing its value.
Avatar of thenone

ASKER

my id is just a regular integer so it would be

comm.execute "update table1 inner join table2 on table1.fieldname = table2.fieldname
set numfield = " & me.text1"


Thanks everybody for their help I will post points this afternoon.
Avatar of thenone

ASKER

one more question if I was just adding the field number then what?
What do you mean?
Avatar of thenone

ASKER

ok so if I have a recordset where it is rs.open"select * from table1 where column=no"

then when I am looping through my records how can I have the recordset be able to change that column one at a time from no to yes.
What does that have to do with this SQL Update question?
Avatar of thenone

ASKER

oops wrong question I posted my mistake what I mean to ask is how can I add the number to the existing number.

Avatar of thenone

ASKER

This is the question I was supposed to post to.My bad.

https://www.experts-exchange.com/questions/21913332/sql-statement.html