cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
821
Views
1
Helpful
4
Replies

(for a project) SQL X Cisco 2023 :)

Bob420
Level 1
Level 1

select replace("naam","from_naam","voornaam");

UPDATE herkansiing
SET afdeling = 'schoonmaken'
WHERE ID= 2;

DELETE FROM herkansiing WHERE tel nummer='0639573920;

zoeken-wijzig-replace-delete-update

4 quarys doen in examen= CRUD- Create-Read-Update-Delete

Myql Database CRUD:

select replace("naam","from_naam","voornaam");

UPDATE herkansiing
SET afdeling = 'schoonmaken'
WHERE ID= 2;

DELETE FROM herkansiing WHERE tel nummer='0639573920;

zoeken-wijzig-replace-delete-update

4 quarys doen in examen= CRUD- Create-Read-Update-Delete

Create:

Create database Studenten;

create table gegevens (
UserID varchar(255),
Firstname varchar(255),
Lastname varchar(255),
Address varchar(255),
city varchar(255)
primary key (userID)
);


Read:

Select * from Studenten;

Select UserID, Firstname,
From gegevens:

Update:

Update gegevens
Set Firstname = ‘hans’, City = ‘Rotterdam’
Where UserID = 1;

Delete:

Delete From gegevens Where Firstname= ‘hans’;

Delete From gegevens;

Delete from Lastname;

-----------------------------------------------------------------
select count (count is rij)
where
from

select count(UserID)
form gegevens1;

select * from gegevens1
where city = 'Rotterdam';
------------------------------------------------------------------
UPdate
set
where

Update gegevens1
set Lastname = 'Lobi', City = 'Amsterdam'
where userID = 26;
------------------------------------------------------------------
Delete
from
where

Delete From gegvens1
where UserID = 'jazz';
------------------------------------------------------------------
change=

select
replace
from
where
between data1, data2
(order by)

select replace("gegevens1","lastname","sirname")
from gegevens1
where lastname;

------------------------------------------------------------------

 

 

1 Accepted Solution

Accepted Solutions

When you have a table you can use:

Insert into "table name"

values(

102868, bob, stone

);

 

This is how it is done

View solution in original post

4 Replies 4

Bob420
Level 1
Level 1

When you have a table you can use:

Insert into "table name"

values(102868, bob, stone

);

 

 

 

When you have a table you can use:

Insert into "table name"

values(

102868, bob, stone

);

 

This is how it is done

Bob420
Level 1
Level 1

Select * from "tablename" where "primary key from table or a collum" = Name ID etc;

 

Bob420
Level 1
Level 1

This might just help!!!!!!!!!

Use Databasename;
 
------------------------------------------ Alters the table you can ADD or Drop a column or Rename etc.
 
Rename Table employees TO workers; 
Rename Table workers TO employees;
 
Alter Table employees
Add phone_number Varchar(15);
 
Alter Table employees
Rename Column phone_number To email;
 
Alter Table employees
Modify Column email Varchar(100);
 
Alter Table employees
Modify email Varchar(100)
After last_name;                          You could also write First 
 
Alter Table employees
Drop Column email;
 
()()()()()()()()()()()()()()()()()()()() Add a column in an existing table, and insert data into that row.
 
Alter Table Employees
Add Column job Varchar(25);
Select * from employees;
 
Update employees
Set job = "Manager"
Where Employee_id = 1;
Select * from employees;
 
------------------------------------------ Pay attention to the datatype (for date that = year then month then day)
 
Insert Into employees
Values (1, "Eugene", "Krabs", 25.50, "2023-01-02");

Select * From employees;
 
------------------------------------------ Inserts values into an existing table.
 
Insert into employees
Values (2, "Squidward", "Tentacles", 15.00, "2023-01-03"),
            (3, "SpongeBob", "Squarepants", 12.50, "2023-01-04"),
            (4, "Patrick", "Star", 12.50, "2023-01-05"),
            (5, "Sandy", "Cheeks", 17.50, "2023-01-06");
 
Select * From employees;
 
------------------------------------------ Inserts values into an existing table, but this one specifies the parts that will be added. 
 
Insert into employees (Employee_ID, First_name, Last_name)
Values (6, "Sheldon", "Plankton");
 
Select * From employees;
 
------------------------------------------ Shows a list of table employee's first name and last name.
 
Select First_name, Last_name
From employees;
 
------------------------------------------ this shows all the values from table employees for employee_id 3.
 
Select *
From employees
Where emplyee_id = 3;
 
Select *
From employees
Where first_name = "SpongeBob"; 
 
------------------------------------------ Shows the data from table employees hourly_pay higher than 15. >= 
 
Select *
From employees
Where hourly_pay >= 15;
 
> can also be used solo, meaning Greater then 
 
>= means Greater than or equal to.
 
------------------------------------------ shows all data from table employees hire_date Lower than 2023-01-03. <=
 
Select 
From employees
Where hire_date <= "2023-01-03";
 
can also be used solo, meaning Lesser than
 
<= means lesser than or equal to.
 
------------------------------------------ AND-OR-NOT-BETWEEN-IN
 
Select * 
From employees
Where hire_date < "2023-01-05" AND job = "cook";
 
Select * 
From employees
Where job = "cook" OR job = "cashier";
 
Select * 
From employees
Where Not job = "manager" AND NOT job = "asst. Manager'';
 
Select * 
From employees
Where hire_date BETWEEN "2023-01-04" AND "2023-01-07'';
 
Select * 
From employees
Where job IN ("cook", "cashier", "janitor");
 
------------------------------------------ Updates the table employees the sets the pay to 10.25 for employee that has employee_id 6.
 
Update employees
Set hourly_pay = 10.25
Where emplyee_id = 6;
 
Select * From employees;
 
------------------------------------------ This also updates the hourly pay but also the hiring date of employee_id 6.
 
Update employees
Set hourly_pay = 10.50,
       hire_date = "2023-01-07"
Where emplyee_id = 6;
 
Select * From employees;
 
()()())()()()())()()()))()()()()()(  Updating from existing data.
 
Update employees
Set frst_name = "Smelldon"
Where employee_id = 6;
 
Select * From employees;
 
------------------------------------------ Sets the hire date to NULL, meaning that there is no data there.
 
Update employees
Set hire_date = NULL
Where employee_id = 6;
 
Select * From employees;
 
------------------------------------------ This updates the hourly pay for all the employees (Or in simpler a whole column)
 
Update employees
Set hourly_pay = 10.25;
 
Select * from employees;
 
------------------------------------------ This deletes from table employees, employee_id 6.
 
Delete From employees
Where enployee_id = 6;
 
Select * From employees;
 
------------------------------------------ WILDCARD-this will show all the first names with the letter S etc.
 
"S%" will show everything that begins with the letter S.
 
"%R" will show everything that ends with the letter R.
 
Select * From employees
Where first_name Like "S%"; 
 
Select * From employees
Where hire_date Like "2023%";
 
Select * From employees
Where last_name Like "%r";
 
------------------------------------------ AVERAGE - Shows an average from column hourly_pay or sum
 
Select AVG(hourly_pay) 
from employees;
 
Select SUM(hourly_pay)
From employees;