Pattern Matching : ( Like , Not Like ) SQL
Like clause is used to match pattern using two wild card characters
_ (underscore) – single unknown character
% (modulo) - Zero or more unknown characters (e.g.)
words staring with ‘t’ - ‘t%’
words ending with ‘t’ - ‘%t’
words containing ‘t’ - ‘%t%’
word with ‘t’ as second letter - ‘_t%’
words with ‘t’ as third last character - ‘%t_ _’
words containing four letter and ‘t’ as second letter - ‘_ t_ _’
Select BName , AVG(Rating) from Product P , Brand B
Where [Link] = [Link] GROUP BY BName
Having BName = “Medimix” OR BName = “Dove” ;
UPDATE Personal
set salary = salary + salary * 5 / 100
where Allowance IS NOT NULL ;
SELECT Name, Salary+Allowance AS “Total Salary”
FROM Personal ;
-----------------------
(a) select avg(salary) from employee group by deptid;
(c) select name from employee
where salary is null order by name ;
(d) select distinct deptid from employee ;
CREATE DATABASE PURCHASE ;
USE PURCHASE ;
CREATE TABLE ITEM
(ITEM_NO NUMERIC(14) PRIMARY KEY,
ITEM_NAME VARCHAR(25) NOT NULL UNIQUE,
ITEM_PRICE FLOAT(10,2),
ITEM_DOE DATE DEFAULT ‘2022-12-31’,
CUST_ID INT(15) REFERENCES CUSTOMER(CUST_ID));
Show Tables ;