Results 1 to 6 of 6
  1. #1
    Join Date
    May 2004
    Posts
    23

    Unanswered: Urgent Query Problem

    Hello,

    I have a table with 6 different fields. two of them are numbers from celular phones. One the phones owned by a company and the other field is related to destination calls, i have about 60000 records.

    I need to make a query that filters the destination calls, in order to know who is calling from our celular phones (Field 1 ) to our celular phones (Field 2 -destination), I just need to know whos calling internly, from our cellular phones to our cellular phones.

    I hope i was able to express my self correctly.

    Thank You

  2. #2
    Join Date
    Jul 2004
    Location
    Southampton, UK
    Posts
    368
    I think I understand what you mean. You want all records where field2 is one of your phones. And field 1 happens to contain the list of all your phone numbers.

    Try this:

    Code:
    SELECT Calls.OurNumber, Calls.CalledNumber
    FROM Calls RIGHT JOIN Calls AS Calls_1 ON Calls.CalledNumber = Calls_1.OurNumber
    WHERE Calls.OurNumber Is Not Null;
    The point is you can re-reference the table you are using by making an alias. In this case we created the alias with "Calls AS Call_1" so we can reference fields from Calls_1 as if it were a different table.

    I used OurNumber and CalledNUmber instead of Field 1 & 2 for clarity. Also the table I used is called Calls.

    HTH
    Chris

  3. #3
    Join Date
    Jul 2004
    Location
    Southampton, UK
    Posts
    368
    Hmm, I think you need to ensure you only get unique records otherwise the query will repeat finds. Try this instead:

    Code:
    SELECT DISTINCTROW Calls.ID, Calls.OurNumber, Calls.CalledNumber
    FROM Calls RIGHT JOIN Calls AS Calls_1 ON Calls.CalledNumber = Calls_1.OurNumber
    WHERE Calls.OurNumber Is Not Null;
    Chris

  4. #4
    Join Date
    May 2004
    Posts
    23
    But where can i put this code?

    In a Query?

    Sorry, im quite new in working with Queries.


    Thank You

  5. #5
    Join Date
    Jul 2004
    Location
    Southampton, UK
    Posts
    368
    Create a new blank query without adding any tables. Click on the SQL button (or View=>SQL). Paste the entire expression in there. You will need to change the expression to use your own table names and field names.

    Then go to datasheet view (View=>datasheet view).

    Chris

  6. #6
    Join Date
    May 2004
    Posts
    23

    Thumbs up

    Thank You.

    I has able to achieve what i as looking for.

    Again, Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •