سؤال

Hi all. My first question here (after much googling/searching).

I am working on migrating a plethora of mailing list spreadsheets to a simple database, using File Maker. One stumbling block is - I need to be able to flag records as inactive, based on if their address exists in a separate table.

ie. To keep it simple:

  • table1 has name, address, and zip.
  • table2 has address and zip.
  • If an address/zip combination in table1 exists also in table2, then it needs to be flagged in table1 as inactive.

Thanks in advance.

هل كانت مفيدة؟

المحلول

First I would create a calculated field called something like addressZIP that combines address and ZIP into a single string.

Then, in table 1, create a calculated field.

Enter this

If (IsEmpty ( FilterValues ( List ( table2::addressZIP ) ; addressZIP )),"","FLAG").

I think that will work, but I'm not positive. I'm not at a computer with FM right now so I can't test it.

نصائح أخرى

You can do a subquery to get the table1 ids and make an update with the IN clause. That can be done with UPDATE FROM too but I think this approach is more understandable. You can begin doing the subquery to check it and later include in the update.

UPDATE
    table1
SET
    flaged = 1
WHERE
    id IN(
          SELECT
            t1.id
          FROM
            table1 t1, table2 t2
          WHERE
            t1.address = t2.address AND t1.zip = t2.zip
    )
مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top