update <table_name> set field_name = 'ABC' || chr(38) || 'DEF' where <where clause>
38 is the ASCII code for ampersand (&), and in this form it will be interpreted as a string, nothing else. I tried it and it worked.
All Education of Pakistani colleges, schools, universities, foreign study, scholarships, results, admissions and courses. Intermediate English Notes, Good-bye Mr. Chips, Online Taleem, Taleem Microsoft, Management Sciences, Computer Sciences Free tutorials, C++ Library, MS Access, Internet of Things, Rural Marketing, Angular2, Framework7, Firebase, Design Thinking, Internet Security, Excel Charts, Computer Security, Conversion Rate Optimization, Business Law, Laravel, SQL Server, Windows10
SELECT "list-of-columns"
FROM table1,table2
WHERE "search-condition(s)"
id | first | last | address | city | state | zip | date | item | price |
---|---|---|---|---|---|---|---|---|---|
id | first | last | address | city | state | zip | date | item | price |
---|---|---|---|---|---|---|---|---|---|
10982 | Wolfgang | Schultz | 300 N. 1st Ave | Yuma | AZ | 85002 | 032299 | snowboard | 45.00 |
10982 | Wolfgang | Schultz | 300 N. 1st Ave | Yuma | AZ | 85002 | 082899 | snow shovel | 35.00 |
10982 | Wolfgang | Schultz | 300 N. 1st Ave | Yuma | AZ | 85002 | 091199 | gloves | 15.00 |
10982 | Wolfgang | Schultz | 300 N. 1st Ave | Yuma | AZ | 85002 | 100999 | lantern | 35.00 |
10982 | Wolfgang | Schultz | 300 N. 1st Ave | Yuma | AZ | 85002 | 022900 | tent | 85.00 |
customer_number | firstname | lastname | address | city | state | zip |
---|---|---|---|---|---|---|
customer_number | date | item | price |
---|
SELECT customer_info.firstname, customer_info.lastname, purchases.item
FROM customer_info, purchases
WHERE customer_info.customer_number = purchases.customer_number;
SELECT customer_info.firstname, customer_info.lastname, purchases.item
FROM customer_info INNER JOIN purchases
ON customer_info.customer_number = purchases.customer_number;
SELECT employee_info.employeeid, employee_info.lastname, employee_sales.comission
FROM employee_info, employee_sales
WHERE employee_info.employeeid = employee_sales.employeeid;
+ | addition |
- | subtraction |
* | multiplication |
/ | division |
% | modulo |
ABS(x) | returns the absolute value of x |
SIGN(x) | returns the sign of input x as -1, 0, or 1 (negative, zero, or positive respectively) |
MOD(x,y) | modulo - returns the integer remainder of x divided by y (same as x%y) |
FLOOR(x) | returns the largest integer value that is less than or equal to x |
CEILING(x) or CEIL(x) | returns the smallest integer value that is greater than or equal to x |
POWER(x,y) | returns the value of x raised to the power of y |
ROUND(x) | returns the value of x rounded to the nearest whole integer |
ROUND(x,d) | returns the value of x rounded to the number of decimal places specified by the value d |
SQRT(x) | returns the square-root value of x |
SELECT round(salary), firstname
FROM employee_info
SELECT col1, SUM(col2)
FROM "list-of-tables"
WHERE col3 IN
(list-of-values);
SELECT col1, SUM(col2)
FROM "list-of-tables"
WHERE col3 BETWEEN value1
AND value2;
SELECT employeeid, lastname, salary
FROM employee_info
WHERE lastname IN ('Hernandez', 'Jones', 'Roberts', 'Ruiz');
SELECT employeeid, lastname, salary
FROM employee_info
WHERE lastname = 'Hernandez' OR lastname = 'Jones' OR lastname = 'Roberts'
OR lastname = 'Ruiz';
SELECT employeeid, age, lastname, salary
FROM employee_info
WHERE age BETWEEN 30 AND 40;
SELECT employeeid, age, lastname, salary
FROM employee_info
WHERE age >= 30 AND age <= 40;
SELECT column1,
SUM(column2)
FROM "list-of-tables"
WHERE "condition1" AND
"condition2";
SELECT employeeid, firstname, lastname, title, salary
FROM employee_info
WHERE salary >= 50000.00 AND title = 'Programmer';
SELECT employeeid, firstname, lastname, title, salary
FROM employee_info
WHERE (salary >= 50000.00) AND (title = 'Programmer');
ORDER BY clause syntax:
ASC = Ascending Order - default
DESC = Descending Order
SELECT employee_id, dept, name, age, salary
FROM employee_info
WHERE dept = 'Sales'
ORDER BY salary, age DESC;
SELECT column1,
SUM(column2)
FROM "list-of-tables"
GROUP BY "column-list"
HAVING "condition";
SELECT dept, avg(salary)
FROM employee
GROUP BY dept;
SELECT dept, avg(salary)
FROM employee
GROUP BY dept
HAVING avg(salary) > 20000;
SELECT column1,
SUM(column2)
FROM "list-of-tables"
GROUP BY "column-list";
SELECT max(salary), dept
FROM employee
GROUP BY dept;
SELECT quantity, max(price)
FROM items_ordered
GROUP BY quantity;
MIN | returns the smallest value in a given column |
MAX | returns the largest value in a given column |
SUM | returns the sum of the numeric values in a given column |
AVG | returns the average value of a given column |
COUNT | returns the total number of values in a given column |
COUNT(*) | returns the number of rows in a table |
SELECT AVG(salary)
FROM employee;
SELECT AVG(salary)
FROM employee;
WHERE title = 'Programmer';
SELECT Count(*)
FROM employees;
SELECT [ALL | DISTINCT] column1[,column2]
FROM table1[,table2]
[WHERE "conditions"]
[GROUP BY "column-list"]
[HAVING "conditions]
[ORDER BY "column-list" [ASC | DESC] ]
SELECT name, age, salary
FROM employee
WHERE age > 50;
= | Equal |
> | Greater than |
< | Less than |
>= | Greater than or equal to |
<= | Less than or equal to |
<> or != | Not equal to |
LIKE | String comparison test |
Example:
SELECT name, title, dept FROM employee WHERE title LIKE 'Pro%';
SELECT DISTINCT age
FROM employee_info;
drop table "tablename"
drop table myemployees_ts0211;
delete from "tablename"
where "columnname"
OPERATOR "value"
[and|or "column"
OPERATOR "value"];
[ ] = optional
delete from employee;
delete from employee
where lastname = 'May';
delete from employee
where firstname = 'Mike' or firstname = 'Eric';
delete from
" followed by the table name, followed by the where clause
which contains the conditions to delete. If you leave off the where
clause, all records will be deleted.update "tablename"
set "columnname" =
"newvalue"
[,"nextcolumn" =
"newvalue2"...]
where "columnname"
OPERATOR "value"
[and|or "column"
OPERATOR "value"];
[] = optional
update phone_book
set area_code = 623
where prefix = 979;
update phone_book
set last_name = 'Smith', prefix=555, suffix=9292
where last_name = 'Jones';
update employee
set age = age+1
where first_name='Mary' and last_name='Williams';
insert into "tablename"
(first_column,...last_column)
values (first_value,...last_value);
first
will match up with the value 'Luke'
, and the column name state
will match up with the value 'Georgia'
.insert into employee
(first, last, age, address, city, state)
values ('Luke', 'Duke', 45, '2130 Boars Nest',
'Hazard Co', 'Georgia');
'string'
create table "tablename"
("column1" "data type",
"column2" "data type",
"column3" "data type");
create table "tablename"
("column1" "data type"
[constraint],
"column2" "data type"
[constraint],
"column3" "data type"
[constraint]);
[ ] = optional
create table employee
(first varchar(15),
last varchar(20),
age number(3),
address varchar(30),
city varchar(20),
state varchar(20));
char(size) | Fixed-length character string. Size is specified in parenthesis. Max 255 bytes. |
varchar(size) | Variable-length character string. Max size is specified in parenthesis. |
number(size) | Number value with a max number of column digits specified in parenthesis. |
date | Date value |
number(size,d) | Number value with a maximum number of digits of "size" total, with a maximum number of "d" digits to the right of the decimal. |
select "column1"
[,"column2",etc]
from "tablename"
[where "condition"];
[] = optional
= | Equal |
> | Greater than |
< | Less than |
>= | Greater than or equal |
<= | Less than or equal |
<> | Not equal to |
LIKE | *See note below |
select first, last, city
from empinfo
where first LIKE 'Er%';
select first, last
from empinfo
where last LIKE '%s';
select * from empinfo
where first = 'Eric';
Sample Table: empinfo | |||||
---|---|---|---|---|---|
first | last | id | age | city | state |
John | Jones | 99980 | 45 | Payson | Arizona |
Mary | Jones | 99982 | 25 | Payson | Arizona |
Eric | Edwards | 88232 | 32 | San Diego | California |
Mary Ann | Edwards | 88233 | 32 | Phoenix | Arizona |
Ginger | Howell | 98002 | 42 | Cottonwood | Arizona |
Sebastian | Smith | 92001 | 23 | Gila Bend | Arizona |
Gus | Gray | 22322 | 35 | Bagdad | Arizona |
Mary Ann | May | 32326 | 52 | Tucson | Arizona |
Erica | Williams | 32327 | 60 | Show Low | Arizona |
Leroy | Brown | 32380 | 22 | Pinetop | Arizona |
Elroy | Cleaver | 32382 | 22 | Globe | Arizona |
select first, last, city from empinfo;
select last, city, age from empinfo
where age > 30;
select first, last, city, state from empinfo
where first LIKE 'J%';
select * from empinfo;
select first, last, from empinfo
where last LIKE '%s';
select first, last, age from empinfo
where last LIKE '%illia%';
select * from empinfo where first = 'Eric';
Weather | |||
---|---|---|---|
city | state | high | low |
Phoenix | Arizona | 105 | 90 |
Tucson | Arizona | 101 | 92 |
Flagstaff | Arizona | 88 | 69 |
San Diego | California | 77 | 60 |
Albuquerque | New Mexico | 80 | 72 |