Guest_imported
New member
- Jan 1, 1970
- 0
Here is my problem: I must find the trunks in a phone switch that have the same number. The trunks' table has the following columns (I'm showing just the ones that I need):
switch trunk_number trunk_name
------ ------------ ----------
ABC 100 xxx
Then, I did the query:
It worked, but I got the result:
switch trunk_number a.trunk_name b.trunk_name
------ ------------ ------------ ------------
ABC 100 xxx yyy
ABC 100 yyy xxx
The second line is useless, so half of the result can always be ignored. Thus, my question is: how can I make a more effcient query?
switch trunk_number trunk_name
------ ------------ ----------
ABC 100 xxx
Then, I did the query:
Code:
SELECT a.switch, a.trunk_number, a.trunk_name, b.trunk_name
FROM trunk a, trunk b
WHERE a.switch = b.switch, a.trunk_number = b.trunk_number, a.trunk_name <> b.trunk_name
It worked, but I got the result:
switch trunk_number a.trunk_name b.trunk_name
------ ------------ ------------ ------------
ABC 100 xxx yyy
ABC 100 yyy xxx
The second line is useless, so half of the result can always be ignored. Thus, my question is: how can I make a more effcient query?