Update multiple column value from one column of the same table

Gazi Enosis

In My table there have two columns. Table structure is:

Combined's data type is varchar(50) and First's data type is int.

ID--Combined -----------First 

1---1.2.3.4-------------- null

2---3.8.6.9-------------- null

I want to convert it to

ID---Combined -----------First 

1---1.2.3.4-------------- 1

2---3.8.6.9-------------- 3

I wrote this lines of code

UPDATE dbo.Test 
SET dbo.Test.First = CAST(SUBSTRING(T.Combined,1,1) AS INT)  
FROM dbo.Test as T 
WHERE T.ID = dbo.Test.ID;

But my code gives that error 'The multi-part identifier "dbo.Test.ID" could not be bound.'

Mureinik

You don't need the update-from syntax here. Since you want your First column to relate to the Combined column of the same row, a simple update statement will do:

UPDATE dbo.Test
SET    dbo.Test.First = CAST(SUBSTRING(dbo.Test.Combined, 1, 1) AS INT)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

Update multiple column value from one column of the same table

From Dev

Update column of one table from same table

From Dev

mysql update table column with multiple values from same table

From Dev

Calculating the value of multiple rows in a column from one table into an other table

From Dev

Calculating the value of multiple rows in a column from one table into an other table

From Dev

Update column from another table column value

From Dev

update column value in table by selecting same table column value

From Dev

Update value of one table with other values of same column with different condition in same table

From Dev

Update value of one table with other values of same column with different condition in same table

From Dev

Update a row if a column value is not the same on other table

From Dev

Update a column of NAs in one data table with the value from a column in another data table

From Dev

Multiple rows with same value in one column

From Dev

Update column value that has one or more same values of other column

From Dev

Table has multiple enteries for the same record I need to get one column value where the other column value is maximum for the same record

From Dev

Update value in a column based on another column in the same table in MYSQL

From Dev

paste same column from multiple files into one

From Dev

Mysql, one column value changes bases on other column in same table

From Dev

MYSQL Join multiple column from same table

From Dev

MYSQL Join multiple column from same table

From Dev

Multiple Column results from the same table

From Dev

select sum() from multiple table with same column

From Dev

PostgreSQL update column from another column in same table

From Dev

Oracle Trigger update column with information from another column in the same table

From Dev

Update column for random value from different table

From Dev

mysql update column value from another table

From Dev

Select / Update records in one table that are LIKE words selected from another table column with multiple records

From Dev

copy one row from a table to another and insert value of one column in same query

From Dev

copy one row from a table to another and insert value of one column in same query

From Dev

MySQL - Update/Set a column in one table equal to MAX value from another table

Related Related

  1. 1

    Update multiple column value from one column of the same table

  2. 2

    Update column of one table from same table

  3. 3

    mysql update table column with multiple values from same table

  4. 4

    Calculating the value of multiple rows in a column from one table into an other table

  5. 5

    Calculating the value of multiple rows in a column from one table into an other table

  6. 6

    Update column from another table column value

  7. 7

    update column value in table by selecting same table column value

  8. 8

    Update value of one table with other values of same column with different condition in same table

  9. 9

    Update value of one table with other values of same column with different condition in same table

  10. 10

    Update a row if a column value is not the same on other table

  11. 11

    Update a column of NAs in one data table with the value from a column in another data table

  12. 12

    Multiple rows with same value in one column

  13. 13

    Update column value that has one or more same values of other column

  14. 14

    Table has multiple enteries for the same record I need to get one column value where the other column value is maximum for the same record

  15. 15

    Update value in a column based on another column in the same table in MYSQL

  16. 16

    paste same column from multiple files into one

  17. 17

    Mysql, one column value changes bases on other column in same table

  18. 18

    MYSQL Join multiple column from same table

  19. 19

    MYSQL Join multiple column from same table

  20. 20

    Multiple Column results from the same table

  21. 21

    select sum() from multiple table with same column

  22. 22

    PostgreSQL update column from another column in same table

  23. 23

    Oracle Trigger update column with information from another column in the same table

  24. 24

    Update column for random value from different table

  25. 25

    mysql update column value from another table

  26. 26

    Select / Update records in one table that are LIKE words selected from another table column with multiple records

  27. 27

    copy one row from a table to another and insert value of one column in same query

  28. 28

    copy one row from a table to another and insert value of one column in same query

  29. 29

    MySQL - Update/Set a column in one table equal to MAX value from another table

HotTag

Archive