| | |
Compare a column's value
Please support our MySQL advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Jun 2009
Posts: 3
Reputation:
Solved Threads: 0
Hi all,
I have a table in which i have 2 columns.i.e. name and ID number as
Table1
--------------------------
Name || ID number
--------------------------
Mark || 204
Roger || 207
Ronny || 209
Robert || 309
mac || 390
black ||
Mark ||
Roger ||
Mac ||
Mark ||
Ronny ||
black || 409
I want to do a query on column 'Name' and where ever i find same name, i want to to insert the same ID number into the corresponding ID number. i.e output should be as:
Table1
--------------------------
Name || ID number
--------------------------
Mark || 204
Roger || 207
Ronny || 209
Robert || 309
mac || 390
black || 409
Mark || 204
Roger || 207
Mac || 390
Mark || 204
Ronny || 209
black || 409
I tried implementing this as:
UPDATE Table1 SET Table1.IDnumber = Table1.IDnumber WHERE Table1.Name LIKE Table1.Name;
But it does not do anything and gives the original table as the output.
I tried it by using 2 tables as well,by creating a duplicate table Table2 of Table1 and then putting a query on Table1.Name as:
UPDATE Table1, Table2 SET Table1.IDnumber=Table2.IDnumber WHERE Table1.Name LIKE Table2.Name;
But in this case also, i dont get the desired output. It shows the same original table only.
Please help...
Thanking you,
I have a table in which i have 2 columns.i.e. name and ID number as
Table1
--------------------------
Name || ID number
--------------------------
Mark || 204
Roger || 207
Ronny || 209
Robert || 309
mac || 390
black ||
Mark ||
Roger ||
Mac ||
Mark ||
Ronny ||
black || 409
I want to do a query on column 'Name' and where ever i find same name, i want to to insert the same ID number into the corresponding ID number. i.e output should be as:
Table1
--------------------------
Name || ID number
--------------------------
Mark || 204
Roger || 207
Ronny || 209
Robert || 309
mac || 390
black || 409
Mark || 204
Roger || 207
Mac || 390
Mark || 204
Ronny || 209
black || 409
I tried implementing this as:
UPDATE Table1 SET Table1.IDnumber = Table1.IDnumber WHERE Table1.Name LIKE Table1.Name;
But it does not do anything and gives the original table as the output.
I tried it by using 2 tables as well,by creating a duplicate table Table2 of Table1 and then putting a query on Table1.Name as:
UPDATE Table1, Table2 SET Table1.IDnumber=Table2.IDnumber WHERE Table1.Name LIKE Table2.Name;
But in this case also, i dont get the desired output. It shows the same original table only.
Please help...
Thanking you,
![]() |
Similar Threads
- compare two ranges in different workbooks and copy data to a 3rd workbook (Visual Basic 4 / 5 / 6)
- How do I Evaluate Null value from database? (ASP.NET)
- how to get the difference between the data of the two files (Visual Basic 4 / 5 / 6)
- JDBC compare the content of two tables (Java)
- Speed of member profiles (DaniWeb Community Feedback)
- order and then compare values from same column (Oracle)
- operator error (C#)
- Problem in Reading Array Variable (C)
- Listbox's Remove item (Visual Basic 4 / 5 / 6)
Other Threads in the MySQL Forum
- Previous Thread: self-referential relationship help please.
- Next Thread: How to Build a database
| Thread Tools | Search this Thread |
agplv3 alfresco api artisticlicense aws bizspark breathalyzer camparingtocolumns changingprices cmg communityjournalism contentmanagement contractors copyright count court crm database design developer development distinct drupal dui ec2 email enterprise eudora facebook form foss gnu government gpl greenit groklaw groupware hiring hyperic images innerjoins insert ip joebrockmeier join journalism keyword keywords kickfire laptop law legal license licensing linux maintenance managing mariadb matchingcolumns metron micromanage microsoft microsoftexchange mindtouch montywidenius mozilla multiple music mysql mysqlcolumnupdating mysqldatetimeordermax() mysqlindex mysqlinternalqueries mysqlquery mysqlsearch news open-xchange opendatabasealliance opengovernment opensource oracle penelope php query referencedesign reorderingcolumns resultset saas select sharepoint simpledb sourcecode spotify sql sugarcrm syntax techsupport thunderbird transparency virtualization






