• What happens when you get a row from Spain? or Portugal? or any other country in Europe?

    You need to create a Countries table to store that information and, preferably, a Continents table as well. Here is the example completed with what I just stated.

    CREATE TABLE Continents(

    ContinentID int CONSTRAINT PK_Continent PRIMARY KEY,

    ContinentName varchar(20)

    );

    INSERT INTO Continents

    VALUES

    (1, 'Europe')

    ,(2, 'America')

    ,(3, 'Asia')

    ,(4, 'Africa')

    ,(5, 'Oceania');

    CREATE TABLE Countries(

    CountryID int CONSTRAINT PK_Countries PRIMARY KEY,

    CountryName varchar(20),

    ContinentID int CONSTRAINT FK_Countries_Continents FOREIGN KEY REFERENCES Continents(ContinentID)

    );

    INSERT INTO Countries

    VALUES

    (1, 'Ireland',1)

    ,(2,'France',1)

    ,(3,'Germany',1)

    ,(4,'Peru',2)

    ,(5,'Australia',5);

    CREATE TABLE #example

    (

    first_nameVARCHAR(15)

    ,surnameVARCHAR(20)

    ,email_addressVARCHAR(60)

    ,countryint CONSTRAINT FK_Example_Countries FOREIGN KEY REFERENCES Countries(CountryID)

    );

    INSERT INTO #example

    VALUES

    ('Andy','Capp','AndyCapp@thecouch.ie',1)

    ,('Asterix','Thegaul','DesMenhirs@obelix.fr',2)

    ,('Hexe','Lilli','Spell@witches.de',3)

    ,('Paddington','Bear','Marmalade@sandwiches.pe',4)

    ,('blinky','bill','Up@bluegumtree.au',5);

    SELECT e.first_name

    ,e.surname

    ,e.email_address

    ,c.CountryName

    FROM #example e

    JOIN Countries c ON e.country = c.CountryID

    ORDER BY c.ContinentID;

    DROP TABLE

    #example, Countries, Continents;

    Luis C.
    General Disclaimer:
    Are you seriously taking the advice and code from someone from the internet without testing it? Do you at least understand it? Or can it easily kill your server?

    How to post data/code on a forum to get the best help: Option 1 / Option 2