spotvillage.blogg.se

Update table mysql
Update table mysql












Then the data capturers can search for all books with the author set to "Unknown author", look up the correct author and fix them.

UPDATE TABLE MYSQL UPDATE

Then update the author_id of all the bad records to point to the Unknown author. What you can do is this: Insert a fake author record like "Unknown author". But the existing interface does an INNER JOIN authors, so all of the books with invalid authors are excluded. There is already an interface for the users to update the book details and the developers don't want to change that just for this problem. It's just the ones that have nonexistent author_ids that are invalid. But there are too many books to go through each one and let's say you know that the ones that have an author_id that corresponds with an actual author are correct. As a DBA you don't want to have to go through all of these books to check what the author_id should be, so the decision is made that the data capturers will fix the books to point to the right authors. But when the database was originally created, no foreign key constraints were set up and later a bug in the front-end code caused some books to be added with invalid author_ids. Let's say you have a table of books and a table of authors. Just for fun, let's add something a bit more interesting. SET Orders.Quantity = Orders.Quantity + 2,

update table mysql

INNER JOIN Orders ON Books.BookID = Orders.BookID To see what this is going to update, you can convert this into a select statement, e.g.: SELECT t2.t1_id, t2.t3_id, t1.a, t2.b, t2.c AS t2_c, t3.c AS t3_cĪn example using the same tables as the other answer: SELECT Books.BookID, Orders.OrderID,












Update table mysql