SQLize Online / PHPize Online  /  SQLtest Online

A A A
Share      Blog   Popular
Copy Format Clear
CREATE TABLE users ( USER_ID INT PRIMARY KEY, USER_NAME VARCHAR(20) NOT NULL, USER_STATUS VARCHAR(20) NOT NULL ); CREATE TABLE logins ( USER_ID INT, LOGIN_TIMESTAMP DATETIME, SESSION_ID INT PRIMARY KEY, SESSION_SCORE INT, FOREIGN KEY (USER_ID) REFERENCES USERS(USER_ID) ) ; INSERT INTO USERS VALUES (1, 'Alice', 'Active'); INSERT INTO USERS VALUES (2, 'Bob', 'Inactive'); INSERT INTO USERS VALUES (3, 'Charlie', 'Active'); INSERT INTO USERS VALUES (4, 'David', 'Active'); INSERT INTO USERS VALUES (5, 'Eve', 'Inactive'); INSERT INTO USERS VALUES (6, 'Frank', 'Active'); INSERT INTO USERS VALUES (7, 'Grace', 'Inactive'); INSERT INTO USERS VALUES (8, 'Heidi', 'Active'); INSERT INTO USERS VALUES (9, 'Ivan', 'Inactive'); INSERT INTO USERS VALUES (10, 'Judy', 'Active'); INSERT INTO LOGINS VALUES (1, '2023-07-15 09:30:00', 1001, 85); INSERT INTO LOGINS VALUES (2, '2023-07-22 10:00:00', 1002, 90); INSERT INTO LOGINS VALUES (3, '2023-08-10 11:15:00', 1003, 75); INSERT INTO LOGINS VALUES (4, '2023-08-20 14:00:00', 1004, 88); INSERT INTO LOGINS VALUES (5, '2023-09-05 16:45:00', 1005, 82); /*CREATE PROCEDURE p1 AS BEGIN SELECT * FROM USERS; END; EXEC p1;

Stuck with a problem? Got Error? Ask ChatGPT!

Copy Clear