Compare a column's value

Reply

Join Date: Jun 2009
Posts: 3
Reputation: me8042 is an unknown quantity at this point 
Solved Threads: 0
me8042 me8042 is offline Offline
Newbie Poster

Compare a column's value

 
0
  #1
Jul 6th, 2009
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,
Reply With Quote Quick reply to this message  
Join Date: Oct 2008
Posts: 2,434
Reputation: adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of adatapost has much to be proud of 
Solved Threads: 439
adatapost's Avatar
adatapost adatapost is offline Offline
Nearly a Posting Maven

Re: Compare a column's value

 
0
  #2
Jul 7th, 2009
i want to to insert the same ID number into the corresponding ID number..
Use insert query.
Failure is not fatal, but failure to change might be. - John Wooden
Reply With Quote Quick reply to this message  
Reply

This thread is more than three months old.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC