• 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
  • Paul Clapham
  • Liutauras Vilda
  • Knute Snortum
  • Bear Bibeault
Sheriffs:
  • Devaka Cooray
  • Jeanne Boyarsky
  • Junilu Lacar
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Carey Brown
  • salvin francis
Bartenders:
  • Tim Holloway
  • Piet Souris
  • Frits Walraven

How to update SQL column

 
Ranch Hand
Posts: 45
  • 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: 45
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Which One is Better in the below Queries:

Query1:



Query2:



Thanks
 
Marshal
Posts: 25194
64
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: 25194
64
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: 45
  • 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
 
There's a hole in the bucket, dear Liza, dear Liza, a hole in the bucket, dear liza, a tiny ad:
Java file APIs (DOC, XLS, PDF, and many more)
https://products.aspose.com/total/java
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!