-4

Two tables are given. In one table we have following columns

productid
product_title
priority
categoryid

and in second table we have

id
productid
color
selling_price
stock

Write a SQL query to select all products in category id 306 with pagination Lets say Result set would have 1000+ such products so we want to paginate the results. In a single request only 100 result need to be return

2 Answers2

0

This seems to be a text-book problem. Still trying to answer. The problem statement is not a straight problem. Here is my answer:

Select Top 100 * from table_2 where productid in (Select (productid, product_title, priority) from table_2 where (categoryid = 306));
0

For paging please read the link :

MySQL Data - Best way to implement paging?

but your query is:

Select 
T1.productid
,T1.product_title
,T1.priority
,T1.categoryid
,T2.id
-- ,T2.productid
,T2.color
,T2.selling_price
,T2.stock
from First_Table T1
inner join to Second_Table T2 on T1.productid=T2.productid
where T1.categoryid=306