Note that there are some explanatory texts on larger screens.

plurals
  1. POCompare two tables input and then output based upon id
    primarykey
    data
    text
    <h3>Background</h3> <p>My problem: I have two tables with information which may or may not exist in both tables. Mainly id, name and account number.</p> <p>Table Structure:</p> <pre><code> Table 1 Table 2 id | a_name |num id | b_name | num ----------------------------------------------- 1 | Bob | 222 | 1 | same | 123 2 | Jane | 1a3 | 2 | Joe | 6a4 3 | same | 321 | 3 | Max | 123 4 | same | 123 | 4 | same | 222 </code></pre> <p>What I must first do is check to see if the name exists from table 1 to table 2, as well as make sure table 2 doesn't have any entries existing in table 1. However, I must also compare and contrast the corresponding account number so that the output would be similar to:</p> <pre><code> Final Table/Array id | name |num --------------------- 1 | Bob | 222 2 | Jane | 1a3 3 | Joe | 6a4 4 | Max | 123 5 | same | 123 6 | same | 222 7 | same | 321 </code></pre> <p>After I compare and contrast the two tables, I need to be able to pull the id correlating to the correct table, and then output those into a selector.</p> <p>Any suggestions on how to proceed, and some tips on coding it correctly?</p> <p>I was thinking to loop them both into separate arrays, use two different in_array statements, and then output the responses based upon a if -else statement...BUT I KNOW this is definately not gonna work because I wont know which table they came from.</p> <p>Recommendations on best methods? I don't want to show you the code I have currently because its a mindboggler that I cant even understand right now.</p> <h3> Issue Clarification:</h3> <p>I only need to output a single distinct (non duplicate) list of names (and numbers) and be able to identify 1) which table its from and 2) the id of the entry from the original table so that I can pull all columns with the corresponding id.</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload