in Education by
tableone a |b| c -------- a1 | |c1 a2 | |c2 a3 | |c3 tabletwo a | b ----- a1|b1 a2|b2 a3|b3 a4|b4 a5|b5 merged a | b | c a1| b1|c1 a2| b2|c2 a3| b3|c3 a4| b4| a5| b5| So I have the two table and I want to merge them. I tried in phpmyadmin these two options: INSERT IGNORE INTO tableone SELECT * FROM tabletwo; REPLACE INTO tableone SELECT * FROM tabletwo; But both do the same (put one table on another), but I want to merge them. So what query must I use? I hope you understand the the question... JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)

1 Answer

0 votes
by
Try these queries back-to-back: INSERT IGNORE INTO tableone (a) SELECT a FROM tabletwo; UPDATE tableone, tabletwo SET tableone.b = tabletwo.b WHERE tableone.a = tabletwo.a; To answer pst, something like this, assuming that tableone does not have a b column: INSERT INTO tablethree (a, b, c) SELECT * FROM (( SELECT tableone.a AS a, tabletwo.b AS b, tableone.c AS c FROM tableone LEFT OUTER JOIN tabletwo ON tableone.a = tabletwo.a ) UNION ( SELECT tabletwo.a AS a, tabletwo.b AS b, tableone.c AS c FROM tableone RIGHT OUTER JOIN tabletwo ON tableone.a = tabletwo.a )) AS x This is untested, but should work. ("Should"...) The UNION is a workaround for MySQL's lack of FULL OUTER JOIN.

Related questions

0 votes
    Hi I have two tables here: Transcript Grade Student_number Course_number Semester Year A 8 MATH2410 Fall 07 ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    Hi I have two tables here: Transcript Grade Student_number Course_number Semester Year A 8 MATH2410 Fall 07 ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Apr 2, 2022 in Education by JackTerrance
0 votes
    The tables are: 1) Producers: id, name 2) Products: id, name, price, category_id, producer_id 3) ... JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 11, 2022 in Education by JackTerrance
0 votes
    What are different tables and default database present in MySQL?...
asked Nov 22, 2020 in Technology by JackTerrance
0 votes
    After reading the chapter, I know these points: I know that data gets highlighted after being selected. I know ... entry and editing. Select the correct answer from above options...
asked Nov 26, 2021 in Education by JackTerrance
0 votes
    How do I merge two dictionaries in a single expression in Python (taking union of dictionaries)?...
asked Jan 9, 2021 in Technology by JackTerrance
0 votes
    I want to combine two views in one dashboard in google analytics report. I want the tracked buttons up ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 19, 2022 in Education by JackTerrance
0 votes
    I want to combine two views in one dashboard in google analytics report. I want the tracked buttons up ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 6, 2022 in Education by JackTerrance
0 votes
    I have two data frames with the closest matching DateTime index, sometimes matching. An object is to merge two of ... I achieve this? Select the correct answer from above options...
asked Jan 19, 2022 in Education by JackTerrance
0 votes
    I have a n...n structure for two tables, makes and models. So far no problem. In a third table ... , JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Mar 19, 2022 in Education by JackTerrance
0 votes
    I have two different source structure tables, but I want to load into single target table? How do I go about it? Explain in detail through mapping flow....
asked Mar 28, 2021 by JackTerrance
0 votes
    I have two queries like so, $q = $dbc -> prepare("UPDATE accounts SET motivation = motivation+100 ... Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked Jul 30, 2022 in Education by JackTerrance
0 votes
    I have some data that looks like this: C:10 R:200 N/A E:3 N/A N:77 I'm trying to ... questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)...
asked May 7, 2022 in Education by JackTerrance
0 votes
    What are data types? Give examples of two data types in SQL / MySQL. Select the correct answer from above options...
asked Dec 21, 2021 in Education by JackTerrance
0 votes
    5. Which key defines a relationship between two tables? (a) Primary key (b) Foreign key (b) Secondary key (d) ... Full form of RDBMS is Select the correct answer from above options...
asked Dec 21, 2021 in Education by JackTerrance
...