database - New to SQL, need help with query -


I have a database table with me that I am trying to produce a query that seems quite simple, But I think I'm messing somewhere because the results are not what they are.

I basically have a table like this:

Table: Data

column:

  line ID Profile Import ID Field ID Product 1 5 Faucet 5 60 Can 2 Faucet 5 65 Het 3 Faucet 5 70 Box 4 6 Faucet 6 60 Fish I Originally In The Line 2 I want to take a "hat" and put it in line 1's "Profile" column, where there is zero value in place I am doing this for many rows.  

In the case of multiple rows, I want to take the "Profile" column and want it to be equal to the "Product" column. I only want what is in the rows, where "id" value matches "import id", and where "field id" 65 is specially "import id" in the example above of "id" 5 5, so I want to take the "product" value "dot" where "field id" is 65 and keep that value in the "profile" column ID 5. There are more than 9000 rows in my table and 600 have to be changed in such a way, different products will be inserted through different IDs.

The result I would like: line ID profile import id field ID product 1 5 Hat 5 60 can 2 0 tap 5 65 hat 3 faucet 5 70 box 4 6 faucet 6 60 fish

I understand this makes sense ...

My query was

UPDATE 'data' SET 'profile' = 'product' WHERE 'id' = 'import id' and 'field id' = 65;

I have also tried a subquery

updated data 'SET' profile '= (SELECT' product where data 'F Ield ID' = 65) where 'id' = 'Import ID';

It was not working and I'm just thinking that I have some arguments that I remember. Thanks to anybody helping you, I am trying to understand it ...

You need to be included in the data; Something:

  Update D1 SET D1. Profile = D2 Products [Data] D1 - Lost Inner Join [Data] D2 - Source On D2 [Import id] = D1 [Id] and d2 [Field id] = 65  

( Note 2 columns swaped ...)


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -