• xxx-593414 - Monday, February 19, 2018 10:17 AM

    ThomasRushton - Monday, February 19, 2018 8:25 AM

    >> I have two Tables (In Ms Sql Server) <<

    Where is the DDL for these alleged tables? Why doesn't your narrative. Follow any ISO 11179 naming rules? Now we have to do everything for you, because you can bother to read even the front end of this form before posting. Are you always this rude to people that you're asking to help you for free?

    Then you screwed up at a more fundamental level. The metadata term. "Master" was derived from tape filesystems in the 1950s. A master tape was a magnetic tape file that held the most current information, this terminology was then carried over in network database systems. It has absolutely no place in RDBMS. Next you confused attributes and entities. Being visited is not a whole separate kind of entity. It is a status (state of being) or attribute of the city.

    CREATE TABLE Cities
    (country_code CHAR(3) NOT NULL, -- look up ISO country code
    city_name VARCHAR(20) NOT NULL,
    PRIMARY KEY (country_code, city_name),
    visitation_count INTEGER NOT NULL DEFAULT 0 CHECK (visitation_status I>= 0));

    >> I want to delete from the MasterCities [sic] table any Country/Cities I have visited
    I don't have any primary keys as the second table is coming from an outside source so need to be able to match by Coountry and City in both tables <<

    Every table to model a distinct and totally different set of entities. You visiting a city does not change its very nature any more than your sitting in an automobile would turn it into a squid. What you're doing is mimicking the way we would have done this with decks of punch cards in the 1950s.

    In some destroying information, let's count the number of times you visited a particular city. Obviously that's going to be zero or more visits. And you'll do it with an update statement

    Please post DDL and follow ANSI/ISO standards when asking for help.