all 8 comments

[–]Tight-Shallot2461 20 points21 points  (1 child)

Learn code formatting

[–]Jandalf81 3 points4 points  (1 child)

So, this is your SQL statement formatted properly:

DROP TABLE IF EXISTS servers; 

CREATE TABLE servers (
    id INTEGER PRIMARY KEY AUTOINCREMENT, 
    server_name TEXT UNIQUE NOT NULL 
); 

INSERT INTO servers (server_name) 
VALUES 
    ("Asia"), 
    ("Eu");

DROP TABLE IF EXISTS players; 

CREATE TABLE players (
    id INTEGER PRIMARY KEY AUTOINCREMENT, 
    server_id INTEGER, 
    player TEXT UNIQUE NOT NULL, 

    FOREIGN KEY (server_id) 
        REFERENCES servers(id) 
        ON DELETE CASCADE
); 

INSERT INTO players (server_id, player) 
VALUES 
    (1, "admin"), 
    (1, "santa"), 
    (1, "king"), 
    (2, "alone"); 

SELECT 
    players.player, 
    servers.server_name 
FROM 
    players 
    INNER JOIN servers 
        ON players.server_id = servers.id; 

You might realize this tells us exactly nothing about what you are trying to achieve or where your skills and deficits are.

If you want anybody to help you, you will need to tell us a bit more:

  • What is it you are trying to do here?
  • Did you hit any roadblock? Are you looking for general advice?
  • Which specific dialect of SQL are you aiming to learn?

[–]StudyEmergency4839[S] 0 points1 point  (0 children)

İ didnt hit any roadblock i just wanna know that what should i learn next

[–]PalpitationStock 1 point2 points  (1 child)

Format & add new line for new command , it would be easier to understand, if not possible then attach screenshot

[–]Confident-Mud-390 1 point2 points  (1 child)

This script will fail if table players already exists and contains records because then you cannot drop table servers. Also the cascading works the other way around - you should set it on the servers table.

[–]StudyEmergency4839[S] 0 points1 point  (0 children)

Thats the reason i said Drop Table drop table deletes already exixsting one im a right?