Carlosdl
29770 pts. | Sep 22 2009 7:24PM GMT
I would recommend to review the join conditions carefully. The reason for the duplicated rows could be there.
CompEng
600 pts. | Sep 23 2009 12:33PM GMT
Carlosdl thanks for the insight. I am novice that all this for me to find that which is causing the duplications, I would not know what to look at and why? Is there any way you can explain what you mean? What is it that makes you say “I would recommend to review the join conditions carefully. The reason for the duplicated rows could be there?” Apparently you see some problems with the way the query is set up?
The (5000Phantoms79w/VNos&othersFromAna) is a table. (IN0140 79 wOE) and (ms0802all79) are query from an AS400 system. I need to link the table (5000Phantoms79w/VNos&othersFromAna) with field “New No” that has my initial new numbers in the column. Then I compare that to the two AS400 queries. If I get matches with the same last four digits from (ms0802all79.PRDNO) or([IN0140 79 wOE].PN) , but numbers in front of the four digits are the same (those that came from the AS400) that are compared to (5000Phantoms79w/VNos&othersFromAna), I need to generate a new number. Which means I go back into the table. I copy the access table into a excel spread sheet. I work with the numbers excel. I then add a column into the access table and then paste the excel column into the new access with the newly generated numbers. Then I run the query again. Read the comments I add to Phil answer above and give me any insight you can. Thanks
Carlosdl
29770 pts. | Sep 23 2009 2:18PM GMT
I didn’t see anything wrong with the query, but whether it is correct or not will depend on the tables structures and the data in them.
For example, if you have a table ADDRESS with these columns (among others): (address, country_id, state_id), and you have a table STATE with these columns (country_id, state_id, state_name), and you want to write a query to show the addresses with the state names. You could write a query like the following, which might look correct, but would return incorrect results (because of incorrect join conditions) if you have states for more than one country in the STATE table.
SELECT a.address,s.state_name FROM address a JOIN state s ON a.state_id = s.state_id;
in this case, the correct query should be:
SELECT a.address,s.state_name FROM address a JOIN state s ON a.country_id = s.country_id AND a.state_id = s.state_id;
Of course, this might not be the case in your query, but I have seen this kind of errors many times, so it is something I always recommend to review.






