Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

How to update SQL column

 
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Table A has two columns

id, sample_id

an id will be associated with multiple sample_id..However both values i.e combined are unique

example,

1, 10
1, 11
1, 12
2, 9
2, 10
2, 11

Now i want to update all the records of "1" to "2" provided it doesn't have a record in "2"

How to do it? Expected Result

1, 10
1, 11
2, 12
2, 9
2, 10
2, 11

Thanks
 
Johnny Joseph
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which One is Better in the below Queries:

Query1:



Query2:



Thanks
 
Marshal
Posts: 25452
65
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Why not just try the two versions and see which you think is better?
 
Paul Clapham
Marshal
Posts: 25452
65
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Paul Clapham wrote:Why not just try the two versions and see which you think is better?



Maybe that sounds a bit terse. But the fact is, it would be a lot easier for you to do that. If you don't then we are going to have a long conversation about what you mean by "better" and the size and structure of your database and its environment and so on. And there's a good chance that in your environment it isn't going to make the least bit of difference which you choose (provided it actually works and does what you want). Remember, you can always change it later if it becomes a problem.
 
Johnny Joseph
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
How to calculate the real speed of a query ? Is there a way a DB can simulate or think of huge record automatically and provide us the results
 
Surfs up space ponies, I'm making gravy without this lumpy, tiny ad:
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic