Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
workindan
Starting Member
21 Posts |
Posted - 2010-11-08 : 15:18:03
|
| Hello, I'm new to sql programming (I've done some of the basics) and had a question:I have two tables: tbl1, tbl2tbl1 has two important fields: 1) item_type 2)item_brand (and other fields)tbl1 has hundreds of records with item_type already completed, but item_brand is nulltbl2 is the reference table, it has 1) item_type and 2) item_brandIt has all the unique types and there brand referenceWhat would be the code to amend tbl1 by referencing the right brand from tbl2? I'm attempting to get it to work on my own before I execute on real world data.Thanks! |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
workindan
Starting Member
21 Posts |
Posted - 2010-11-09 : 12:59:37
|
| [code](table: people)name id item_type item_brandmarge 0 circle bob 1 block jill 2 squaremasdf 3 circle adf 4 triangle (table: itemref)item_type item_brandblock mattellcircle helpersquare mattyztriangle nathanadfadsf 5 block [/code]As I understand it, an UPDATE using INNER JOIN would work. I seem to be confused on the syntax, though... |
 |
|
|
workindan
Starting Member
21 Posts |
Posted - 2010-11-09 : 13:14:35
|
| Here's the one I'm using:UPDATE people set item_brand=itemref.item_brand FROM people INNER JOIN itemref on people.item_type=itemref.item_type WHERE people.item_brand is null;But when I try to execute it (these are test tables in Access 2003), I get this: "Syntax error (missing operator) in query expression 'itemref.item_brand FROM people INNER JOIN itemref on people.item_type=itemref.item_type' |
 |
|
|
|
|
|