1.SQL part2
1.To create class table
CREATE TABLE class( class_id INT PRIMARY KEY, class_name VARCHAR(50), FOREIGN KEY (teacher_id) REFERENCES teacher(teacher_id) );
2.to create teacher table
CREATE TABLE teacher ( teacher_id INT PRIMARY KEY, teacher_name VARCHAR(100), age INT, subject VARCHAR(50), experience INT );
3.insert teachers data in to table
INSERT INTO teacher(teacher_id,teacher_name,age,subject,experience) VALUES (101, 'Sk. Sohana', 30, 'Mathematics', 5), (102, 'U. Munisekhar', 35, 'English', 8), (103, 'SK. Nellu', 40, 'Science', 10), (104, 'A. Venu', 28, 'History', 3);
4.insert class data in to table
INSERT INTO class(class_id,class_name,teacher_id) (9, 'Math', 101), (10, 'English', 102), (11, 'Science', 103), (12, 'History', 104);
teacher Table
teacher_id | teacher_name | age | subject | experience |
---|---|---|---|---|
101 | Sk. Sohana | 30 | Mathematics | 5 |
102 | U. Munisekhar | 35 | English | 8 |
103 | SK. Nellu | 40 | Science | 10 |
104 | A. Venu | 28 | History | 3 |
105 | S. Jagadeesh | 28 | Telugu | 3 |
class Table
class_id | class_name | teacher_id |
---|---|---|
9 | Math | 101 |
10 | English | 102 |
11 | Science | 103 |
12 | History | 104 |
- To get the data from the Class table
SELECT * FROM class;
| class_id | class_name | teacher_id | |----------|--------------------|------------| | 9 | Math | 101 | | 10 | English | 102 | | 11 | Science | 103 | | 12 | History | 104 |
- To get the data from the teacher table 5 year experience teachers
SELECT * FROM teacher WHARE experience >5
| teacher_id | teacher_name | age | subject | experience | |------------|--------------------|-----|---------------|------------| | 102 | U. Munisekhar | 35 | English | 8 | | 103 | SK. Nellu | 40 | Science | 10 |
7.to find Munisekhar teacher deatails
SELECT * FROM teacher WHERE teacher_name='U. Munisekhar'
| teacher_id | teacher_name | age | subject | experience | |------------|--------------------|-----|---------------|------------| | 102 | U. Munisekhar | 35 | English | 8 |
8.find Sk. Sohana teacher experience?
SELECT experience FROM teacher WHERE teacher_name='Sk. Sohana';
| experience | |------------| | 8 |
9.find the teachers name and age WHERE age bitwen 29 to 39
SELECT name,age FROM teacher WHERE age BETWEEN 29 AND 39;
| teacher_name | age | |--------------------|-----| | Sk. Sohana | 30 | | U. Munisekhar | 35 |
10.to find class name and teacher name to use left join
SELECT class.class_name, teacher.teacher_name FROM class RIGHT JOIN teacher ON class.teacher_id=teacher.teacher_id;
| class_name | teacher_name | |------------|--------------------| | Math | Sk. Sohana | | English | U. Munisekhar | | Science | SK. Nellu | | History | A. Venu |
11.to find class name and ALL teachers names to use right join
SELECT class.class_name, teacher.teacher_name FROM class RIGHT JOIN teacher ON class.teacher_id=teacher.teacher_id;
| class_name | teacher_name | |------------|--------------------| | Math | Sk. Sohana | | English | U. Munisekhar | | Science | SK. Nellu | | History | A. Venu | | NULL | S. Jagadeesh |
12.to find class name and teachers names to use inner join
SELECT class.class_name, teacher.teacher_name FROM class INNER JOIN teacher ON class.teacher_id=teacher.teacher_id;
| class_name | teacher_name | |------------|--------------------| | Math | Sk. Sohana | | English | U. Munisekhar | | Science | SK. Nellu | | History | A. Venu |
13.to find munisekhar class display heis name and calss
SELECT teacher.teacher.name, class.class_name FROM teacher RIGHT JOIN class ON teacher.teacher_id=class.teacher_id WHERE teacher.teacher_name = 'U. Munisekhar';
| teacher_name | class_name | |--------------------|------------| | U. Munisekhar | English |
The above is the detailed content of SQL || MySQL || By Munisekhar Udavalapati. For more information, please follow other related articles on the PHP Chinese website!

MySQLviewshavelimitations:1)Theydon'tsupportallSQLoperations,restrictingdatamanipulationthroughviewswithjoinsorsubqueries.2)Theycanimpactperformance,especiallywithcomplexqueriesorlargedatasets.3)Viewsdon'tstoredata,potentiallyleadingtooutdatedinforma

ProperusermanagementinMySQLiscrucialforenhancingsecurityandensuringefficientdatabaseoperation.1)UseCREATEUSERtoaddusers,specifyingconnectionsourcewith@'localhost'or@'%'.2)GrantspecificprivilegeswithGRANT,usingleastprivilegeprincipletominimizerisks.3)

MySQLdoesn'timposeahardlimitontriggers,butpracticalfactorsdeterminetheireffectiveuse:1)Serverconfigurationimpactstriggermanagement;2)Complextriggersincreasesystemload;3)Largertablesslowtriggerperformance;4)Highconcurrencycancausetriggercontention;5)M

Yes,it'ssafetostoreBLOBdatainMySQL,butconsiderthesefactors:1)StorageSpace:BLOBscanconsumesignificantspace,potentiallyincreasingcostsandslowingperformance.2)Performance:LargerrowsizesduetoBLOBsmayslowdownqueries.3)BackupandRecovery:Theseprocessescanbe

Adding MySQL users through the PHP web interface can use MySQLi extensions. The steps are as follows: 1. Connect to the MySQL database and use the MySQLi extension. 2. Create a user, use the CREATEUSER statement, and use the PASSWORD() function to encrypt the password. 3. Prevent SQL injection and use the mysqli_real_escape_string() function to process user input. 4. Assign permissions to new users and use the GRANT statement.

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters


Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

Video Face Swap
Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Safe Exam Browser
Safe Exam Browser is a secure browser environment for taking online exams securely. This software turns any computer into a secure workstation. It controls access to any utility and prevents students from using unauthorized resources.

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

SublimeText3 Chinese version
Chinese version, very easy to use

SublimeText3 Mac version
God-level code editing software (SublimeText3)
