This document contains SQL queries and HTML code. The SQL section includes 16 queries on an EMP table with sample data. Queries retrieve and filter employee data by name, salary, department, hire date and more. The HTML section includes one form with fields to collect a user's name, password, country, computer type, comments and a submit button.
3. 14 rows in set (0.02 sec)
QUERY 2 :
Query to display EmpName, Sal and Sal added with Comm from table EMP.
mysql> SELECT EmpName, Sal, Sal+Comm
-> FROM EMP;
+---------+------+----------+
| EmpName | Sal |Sal+Comm |
+---------+------+----------+
| SMITH
|
0 |
NULL |
| ALLEN
| 1600 |
1900 |
| WARD
| 1250 |
1750 |
| JONES
| 2975 |
NULL |
| MARTIN | 1250 |
2650 |
| BLAKE
| 2850 |
NULL |
| CLARK
| 2450 |
NULL |
| SCOTT
| 3000 |
NULL |
| KING
| 5000 |
NULL |
| TURNER | 1500 |
1500 |
| ADAMS
| 1100 |
NULL |
| JAMES
| 950 |
NULL |
| FORD
| 3000 |
NULL |
| MILLER | 1300 |
NULL |
+---------+------+----------+
14 rows in set (0.03 sec)
QUERY 3 :
Query to display distinct Sal of employees from table EMP.
mysql> SELECT DISTINCT Sal
-> FROM EMP;
+------+
| Sal |
+------+
| 800 |
| 1600 |
| 1250 |
| 2975 |
| 2850 |
| 2450 |
| 3000 |
| 5000 |
| 1500 |
| 1100 |
| 950 |
| 1300 |
+------+ 12 rows in set (0.00 sec)
4. QUERY 4 :
Query to display EmpName and Sal of Employees whose salary is greater than or
equal to 3000 from table EMP.
mysql> SELECT EmpName, Sal
-> FROM Emp
-> WHERE Sal>=3000;
+-------+---------+-----------+------+------------+------+------+--------+
| EmpNo | EmpName | Job
| Mgr |Hiredate | Sal | Comm | DeptNo |
+-------+---------+-----------+------+------------+------+------+--------+
| 7788 | SCOTT
| ANALYST
| 7566 | 09-DEC-82 | 3000 | NULL |
20 |
| 7839 | KING
| PRESIDENT | NULL | 17-NOV-81 | 5000 | NULL |
10 |
| 7902 | FORD
| ANALYST
| 7566 | 03-DEC-81 | 3000 | NULL |
NULL |
+-------+---------+-----------+------+------------+------+------+------3 rows in set (0.00 sec)
QUERY 5 :
Query to display employee EmpName, Sal and DeptNo who are not getting
commission from table EMP.
mysql> SELECT EmpName, Sal, DeptNo
-> FROM Emp
-> WHERE Comm IS NULL;
+---------+------+--------+
| EmpName | Sal |DeptNo |
+---------+------+--------+
| SMITH
| 800 |
NULL |
| JONES
| 2975 |
20 |
| BLAKE
| 2850 |
30 |
| CLARK
| 2450 |
10 |
| SCOTT
| 3000 |
20 |
| KING
| 5000 |
10 |
| ADAMS
| 1100 |
20 |
| JAMES
| 950 |
30 |
| FORD
| 3000 |
NULL |
| MILLER | 1300 |
NULL |
+---------+------+--------+ 10 rows in set (0.00 sec)
QUERY 6 :
Query to display employee Number, name, sal and sal*12 as Annual Salary whose
commission is not NULL from table Emp.
mysql> SELECT EmpNO, EmpName, Sal, Sal*12 "Annual Salary"
-> FROM EMP
-> WHERE Comm IS NOT NULL;
+-------+---------+------+---------------+
| EmpNO | EmpName | Sal | Annual Salary |
+-------+---------+------+---------------+
| 7499 | ALLEN
| 1600 |
19200 |
| 7521 | WARD
| 1250 |
15000 |
| 7654 | MARTIN | 1250 |
15000 |
| 7844 | TURNER | 1500 |
18000 |
+-------+---------+------+---------------+
5. 4 rows in set (0.00 sec)
QUERY 7 :
Query to display employee name and salary of those employee who don’t have
their salary in the range of 1500 to 2000
mysql> SELECT EmpName, Sal
-> FROM EMP
-> WHERE Sal NOT BETWEEN 1500 AND 2000;
+---------+------+
| EmpName | Sal |
+---------+------+
| SMITH
| 800 |
| WARD
| 1250 |
| JONES
| 2975 |
| MARTIN | 1250 |
| BLAKE
| 2850 |
| CLARK
| 2450 |
| SCOTT
| 3000 |
| KING
| 5000 |
| ADAMS
| 1100 |
| JAMES
| 950 |
| FORD
| 3000 |
| MILLER | 1300 |
+---------+------+
12 rows in set (0.00 sec)
QUERY 8 :
Query to display name, job, salary, and HireDate of employees who are
hired between February 20, 1981, and May 1, 1981. Order the query in
ascending order of HireDate.
mysql> SELECT EmpName, Job, Sal, Hiredate
-> WHERE Hiredate BETWEEN '20-Feb-81' AND '01-May-81'
-> ORDER BY Hiredate;
+---------+-----------+------+------------+
| EmpName | Job
| Sal |Hiredate |
+---------+-----------+------+------------+
| ALLEN
| SALESMAN | 1600 | 20-FEB-81 |
| WARD
| SALESMAN | 1250 | 22-FEB-81 |
| JONES
| MANAGER
| 2975 | 02-APR-81 |
| BLAKE
| MANAGER
| 2850 | 01-MAY-81 |
+---------+-----------+------+------------+
14 rows in set (0.00 sec)
6. QUERY 9 :
Query to display the name, job title and salary of employee who are not
Manager.
mysql> SELECT EmpName, Job, Sal
-> FROM EMP
-> WHERE JOB NOT IN("MANAGER");
+---------+-----------+------+
| EmpName | Job
| Sal |
+---------+-----------+------+
| SMITH
| CLERK
| 800 |
| ALLEN
| SALESMAN | 1600 |
| WARD
| SALESMAN | 1250 |
| MARTIN | SALESMAN | 1250 |
| SCOTT
| ANALYST
| 3000 |
| KING
| PRESIDENT | 5000 |
| TURNER | SALESMAN | 1500 |
| ADAMS
| CLERK
| 1100 |
| JAMES
| CLERK
| 950 |
| FORD
| ANALYST
| 3000 |
| MILLER | CLERK
| 1300 |
+---------+-----------+------+
11 rows in set (0.00 sec)
QUERY 10 :
Query to display the name of employee whose name contains æAÆ as third
alphabet.
mysql> SELECT EmpName
-> FROM EMP
-> WHERE EmpName LIKE "__A%";
+---------+
| EmpName |
+---------+
| BLAKE
|
| CLARK
|
| ADAMS
|
+---------+
3 rows in set (0.01 sec)
QUERY 11 :
7. Query to display the name of employee whose name contains æTÆ as the last
alphabet.
mysql> SELECT EmpName
-> FROM EMP
-> WHERE EmpName LIKE "%T";
+---------+
| EmpName |
+---------+
| SCOTT
|
+---------+
1 row in set (0.00 sec)
QUERY 12 :
Query to display the name of employee whose name contains æMÆ as first
alphabet &æLÆ as third alphabet.
mysql> SELECT EmpName
-> FROM EMP
-> WHERE EmpName LIKE "M_L%";
+---------+
| EmpName |
+---------+
| MILLER |
+---------+
1 row in set (0.02 sec)
QUERY 13 :
Query to display the name of employee who is having æLÆ as any alphabet of
the name.
mysql> SELECT EmpName
-> FROM EMP
-> WHERE EmpName LIKE "%L%";
+---------+
| EmpName |
+---------+
| ALLEN
|
| BLAKE
|
| CLARK
|
| MILLER |
+---------+
4 rows in set (0.00 sec)
QUERY 14 :
Query to display the current system date.
8. mysql> SELECT sysdate() FROM dual;
+-------------+
| SYSDATE() |
+-------------+
| 03-Nov-11
|
+-------------+
1 row in set (0.01 sec)
QUERY 15 :
Query to display employee number, name, salary, salary increase by 15%.
Label the column as New Salary.
mysql> SELECT EmpNo, EmpName, Sal, Sal*.15 "New Salary"
-> FROM EMP;
+-------+---------+------+------------+
| EmpNo | EmpName | Sal | New Salary |
+-------+---------+------+------------+
| 7369 | SMITH
| 800 |
920.00 |
| 7499 | ALLEN
| 1600 |
1840.00 |
| 7521 | WARD
| 1250 |
1437.50 |
| 7566 | JONES
| 2975 |
3421.25 |
| 7654 | MARTIN | 1250 |
1437.50 |
| 7698 | BLAKE
| 2850 |
3277.50 |
| 7782 | CLARK
| 2450 |
2817.50 |
| 7788 | SCOTT
| 3000 |
3450.00 |
| 7839 | KING
| 5000 |
5750.00 |
| 7844 | TURNER | 1500 |
1725.00 |
| 7876 | ADAMS
| 1100 |
1265.00 |
| 7900 | JAMES
| 950 |
1092.50 |
| 7902 | FORD
| 3000 |
3450.00 |
| 7934 | MILLER | 1300 |
1495.00 |
+-------+---------+------+------------+
14 rows in set (0.05 sec)
QUERY 16 :
Query that produces display in the following format
<employee name> Earns $<salary> Monthly and working as <Job >
9. mysql> SELECT EmpName, 'earns $', Sal, 'Monthly and working as', Job
-> FROM EMP;
+---------+---------+------+------------------------+-----------+
| EmpName | earns $ | Sal | monthly and working as | Job
|
+---------+---------+------+------------------------+-----------+
| SMITH
| earns $ | 800 | monthly and working as | CLERK
|
| ALLEN
| earns $ | 1600 | monthly and working as | SALESMAN |
| WARD
| earns $ | 1250 | monthly and working as | SALESMAN |
| JONES
| earns $ | 2975 | monthly and working as | MANAGER
|
| MARTIN | earns $ | 1250 | monthly and working as | SALESMAN |
| BLAKE
| earns $ | 2850 | monthly and working as | MANAGER
|
| CLARK
| earns $ | 2450 | monthly and working as | MANAGER
|
| SCOTT
| earns $ | 3000 | monthly and working as | ANALYST
|
| KING
| earns $ | 5000 | monthly and working as | PRESIDENT |
| TURNER | earns $ | 1500 | monthly and working as | SALESMAN |
| ADAMS
| earns $ | 1100 | monthly and working as | CLERK
|
| JAMES
| earns $ | 950 | monthly and working as | CLERK
|
| FORD
| earns $ | 3000 | monthly and working as | ANALYST
|
| MILLER | earns $ | 1300 | monthly and working as | CLERK
|
+---------+---------+------+------------------------+-----------+
14 rows in set (0.00 sec)
HTML PROGRAMS
HTML PROGRAM 1:
10. <HTML>
<BODY>
<P ALIGN=CENTER>
<CENTER.<H1>PLEASE ENTER YOUR DETAILS</H1></CENTER>
</P>
<FORM METHOD=POST>
<P>Person's Name:
<INPUT TYPE="text" NAME="persons-name" SIZE="40" MAXLENGTH="40">
<INPUT TYPE="hidden" NAME="recipient" SIZE="40" MAXLENGTH="40">
</P>
<P>Password:
<INPUT TYPE="password" NAME="password" SIZE="10" MAXLENGTH="40">
</P>
<P>Please Place me on your mailing list :
<INPUT TYPE="checkbox" NAME="mailing-list" VALUE="Yes" checked>
</P>
<P>What Country do you Live in ?
<SELCT Name="Country">
<OPTION VALUE="IND">India
<OPTION VALUE="USA">United States
<OPTION VALUE="CA">Canada
<OPTION VALUE="FR">France
11. <OPTION VALUE="SPR">Singapore
</SELECT>
</P>
<P>Type of Computer you have :
<INPUT TYPE="radio" NAME="Comp-Typ" VALUE="486DX">486 DX
<INPUT TYPE="radio" NAME="Comp-Typ" VALUE="486SX">486 SX
<INPUT TYPE="radio" NAME="Comp-Typ" VALUE="Pentium2">Pentium II
<INPUT TYPE="radio" NAME="Comp-Typ" VALUE="Pentium3">Pentium III
<INPUT TYPE="radio" NAME="Comp-Typ" VALUE="Pentium4">Pentium IV
</P>
<P>Comments :
<TEXTAREA NAME="comments" ROWS="5" COLS="25"></TEXTAREA>
</P>
<P>
<INPUT TYPE="submit" NAME="Request" VALUE="Submit This Form">
<INPUT TYPE="reset" NAME="Clear" VALUE="Clear Form and Start Over">
</P>
</FORM>
</BODY>
</HTML>
HTML PROGRAM 2:
13. <li>Tea</li>
<li>Milk</li>
</ul>
</body>
</html>
HTML PROGRAM 3:
<html>
<body>
<dl>
<dt>DRDO
<dd>The Defence Research and Development Organisation is an agency of the
Republic of India, responsible for the development of technology for use by the
military, headquartered in New Delhi, India. It was formed in 1958 by the
merger of the Technical Development Establishment and the Directorate of
Technical Development and Production with the Defence Science Organisation.
</dl>
</body>
</html>
HTML PROGRAM 4:
16. HTML PROGRAM 6:
<html>
<head>
<title>
xii-ip-2-basic html tag HTML-I </title>
</head>
<body leftmargin="60" topmargin=90 background = H:KVSlogo.jpg >
<H1> LEVEL 1 HEADING TAG BY DEFAULT LEFT ALIGN </H1>
<H2 ALIGN = CENTER> LEVEL 2 HEADING </H2>
<H3 ALIGN = RIGHT > LEVEL 3 HEADING </H3>
<H4 ALIGN = LEFT > LEVEL 4 HEADING </H4>
<H5> LEVEL 5 HEADING </H5>
<H6> LEVEL 6 HEADING </H6>
HELLO STUDENT! WE ALL WISH A VERY BEST OF LUCK FOR YOUR EXAM. AND
BELIEVE THAT U ALL WILL SHOW YOUR BEST. WE PRAY TO GOD TO GIVE YOUR BEST LUCK
IN THIS EXAM. </P>
<P> Notepad is a basic text editor that you can use to create
simple documents. The most common use for Notepad is to view or edit text
(.txt) files, but many users find Notepad a simple tool for creating Web
pages.</P>
<P ALIGN = RIGHT>Because Notepad supports only very basic
formatting, you cannot accidentally save special formatting in documents that
need to remain pure text. This is especially useful when creating HTML
documents for a Web page because special characters or other formatting may
not appear in your published Web page or may even cause errors.</P>
<P ALIGN = CENTER>You can save your Notepad files as Unicode,
ANSI, UTF-8, or big-endian Unicode. These formats provide you greater
flexibility when working with documents that use different character sets.
</P>
<P ALIGN = LEFT>Notepad allows you to create and open documents in several
different formats: ANSI, Unicode, big-endian Unicode, or UTF-8. These formats
allow you to work with documents that use different character sets.</P>
<BASEFONT SIZE=2> THIS IS
A BOOK 2<BR>
<BASEFONT SIZE=3> THIS IS
A BOOK 3<BR>
<BASEFONT SIZE=4> THIS IS
A BOOK 4<BR>
<BASEFONT SIZE=5> THIS IS
A BOOK 5<BR>
<BASEFONT SIZE=6> THIS IS
A BOOK 6<BR>
17. <BASEFONT SIZE=7> THIS IS
<BASEFONT SIZE=8> THIS IS
<BASEFONT SIZE=-2> THIS IS
A BOOK 7<BR>
A BOOK 8<BR>
A BOOK 6<BR>
'<FONT> HELLO </FONT>
<FONT SIZE = 1 COLOR = BLUE > HELLO 1 </FONT>
<FONT SIZE = 1 COLOR = #0000FF > HELLO 1 </FONT>
<FONT SIZE = 2 COLOR = RED > HELLO 2 </FONT>
<FONT SIZE = 2 COLOR = #FF0000 > HELLO 2 </FONT>
<FONT SIZE = 3 COLOR = GREEN> HELLO 3 </FONT>
<FONT SIZE = 3 COLOR = #008000> HELLO 3 </FONT>
<FONT SIZE = 4 COLOR = TEAL > HELLO 4 </FONT>
<FONT SIZE = 4 COLOR = TEAL > HELLO 4 </FONT>
<FONT SIZE = 5 COLOR = AQUA > HELLO 5 </FONT>
<FONT SIZE = 5 COLOR = #00FFFF > HELLO 5 </FONT><BR>
<FONT SIZE = 6 COLOR = LIME > HELLO 6 </FONT>
<FONT SIZE = 6 COLOR = #00FF00 > HELLO 6 </FONT>
<FONT SIZE = 7 COLOR = MAROON> HELLO 7 </FONT>
<FONT SIZE = 7 COLOR = #800000> HELLO 7 </FONT>
<FONT SIZE = 8 COLOR =OLIVE > HELLO 8 </FONT>
<FONT SIZE = 8 COLOR =#808000 > HELLO 8 </FONT>
<FONT SIZE = 3 COLOR = PURPLE> HELLO 3 </FONT>
<FONT SIZE = 3 COLOR =#800080> HELLO 3 </FONT>
<FONT SIZE = +2 COLOR = SILVER> HELLO 5 </FONT>
<FONT SIZE = +2 COLOR = C0C0C0> HELLO 5 </FONT>
<FONT COLOR = YELLOW> HELLO
</FONT>
<FONT COLOR = FFFF00> HELLO
</FONT>
<FONT COLOR = GREY> HELLO </FONT>
<FONT COLOR = 808080> HELLO </FONT>
<FONT FACE = "Verdana"> VERDANA </FONT>
<FONT FACE = "Comic Sans MS"> Comic Sans MS </FONT>
<FONT FACE = "Arial Black"> Arial Black </FONT><BR>
<FONT FACE = "Arial Black, Verdana"> VERDANA </FONT>
<FONT FACE = "BRH Devanagari, Verdana, Arial Black"> VERDANA </FONT>
<HR> ONE
<HR SIZE=1> ONE SIZE MEANS THICKNESS
<HR SIZE=2> TWO
<HR SIZE=12> ABOVE IS 12
<HR SIZE=36> ABOVE IS 36
<HR SIZE=72> ABOVE IS 72
<HR SIZE=100> ABOVE IS 100
<HR SIZE=2 WIDTH =25> ABOVE 25
<HR SIZE=2 WIDTH =50> ABOVE 50
<HR SIZE=2 WIDTH =50%> ABOVE 50%
<HR SIZE=2 WIDTH =70> ABOVE 70
<HR SIZE=2 WIDTH =100> ABOVE 100
<HR SIZE=2 WIDTH =100%> ABOVE 100%
<HR SIZE = 12> ABOVE IS 3-D RULE
<HR NOSHADE SIZE = 12> ABOVE IS 2-D RULE
<!--- THIS IS A SINGLE LINE COMMENT PART --->
<!--- THIS IS MULTIPLE LINES COMMENT PART
HELLO STUDENTS
WE ARE STUDING HTML--->
</body>
</html>