SELECT * FROM student WHERE name LIKE
(SELECT name FROM student WHERE mark =86)
| id | name | class | mark | |
|---|---|---|---|---|
| 28 | Rojj Base | Seven | 86 |
SELECT * FROM student WHERE class NOT IN
(SELECT DISTINCT(class) FROM student)
This query will return if any record is there where class data is not there.
SELECT * FROM student WHERE
class = ANY(SELECT DISTINCT(class) FROM student)
We will get all the records as we don't have any blank class data
SELECT * FROM student WHERE
mark = (SELECT MAX(mark) FROM student)
| id | name | class | mark | |
|---|---|---|---|---|
| 33 | Kenn Rein | Six | 96 |
SELECT * FROM student WHERE class NOT IN
(SELECT MAX(mark) FROM student WHERE class= ANY(SELECT DISTINCT class FROM student))
SELECT * FROM `student` WHERE id NOT IN
(SELECT f_id from student_football UNION select b_id from student_baseball)
You can get similar result by using LEFT JOIN of three tables.
Author
🎥 Join me live on YouTubePassionate about coding and teaching, I publish practical tutorials on PHP, Python, JavaScript, SQL, and web development. My goal is to make learning simple, engaging, and project‑oriented with real examples and source code.
| mallamma.b.hataraki | 02-08-2010 |
| please can you post more subqueries examples to retrieve data from more than one table. | |
| Noel | 13-04-2012 |
| How to put a total at the bottom of a detailed report. for example query database Select product_code,description,net_sales from tablex how do you put a total at the end of the report below column net_sales. | |
| rajavel | 31-05-2014 |
| awesome explain;;;; | |
| tgfughjgu | 10-07-2014 |
| [ll'w to put a total at the bottom of a detailed report. for example query database Select product_code,description,net_sales from tablex how do you put a total at the end of the report below column net_sales. rajavel 31-05-2014 | |
| Abdulsalam Saidu | 10-12-2016 |
| ...Please more example on the subquery... | |