whereclause. An orderby clause is not allowed in a SQLite Queries. And this can be nested within other SQLite Queries. SQLite Queries are used in where, having, from and in select clauses.
SQLite subqueries are used to extract data from the database in a readable format according to the request given by the user.And SQLite Queries is a query inside another SQLite query and implanted inside the where clause.And a subquery is a SQL query nested within a larger query.A subquery can be considered as an internal query,which is a SQL query set as a part of another query called as external queries.
And a SQLite subqueries may happens in:
A subquery is typically included inside the where condition of another SQL select proclamation.And these subqueries will utilize the comparison operators like =,> or <.These comparison operator can also be a multiple-row operator such as NOT IN ,IN.During the process of subqueries,the internal query will be executed first and passes these internal query to external query.
Select select_list from table where expr operator.
sqlite> create table employees(Emp_id int,First_Name varchar2(20),Last_Name varchar2(20),Email varchar2(20),Mobile number int,Salary int); sqlite> insert into employees values(1001,'John','David','David@gmail.com',9701662524,25000); sqlite> insert into employees values(1002,'Mike','Tyson','Tyson@gmail.com',9701624265,25200); sqlite> insert into employees values(1003,'David','Warner','Warner@gmail.com',9701657261,26000); sqlite> insert into employees values(1004,'Malik','Winner','Winner@gmail.com',9725254485,26000); sqlite> insert into employees values(1005,'Jack','Wolfner','Wolfner@gmail.com',9441203170,26000); sqlite> select * from employees; 1001|John|David|David@gmail.com|9701662524|25000 1002|Mike|Tyson|Tyson@gmail.com|9701624265|25200 1003|David|Warner|Warner@gmail.com|9701657261|26000 1004|Malik|Winner|Winner@gmail.com|9725254485|26000 1005|Jack|Wolfner|Wolfner@gmail.com|9441203170|26000 sqlite> select First_Name,Last_Name,salary from employees where salary>(select salary from employees where Last_Name='David'); Mike|Tyson|25200 David|Warner|26000 Malik|Winner|26000 Jack|Wolfner|26000
In the above example a query with in an subquery has been as been evaluated,in which the subquery will be executed first and the output of the subquery will be given as input to main query.