Select records until a specific record (1 Viewer)

amir0914

Registered User.
Local time
Today, 16:25
Joined
May 21, 2018
Messages
151
Hi all,
I have a table of Product names and I need a sql code to pull products name till a speciific products name, like :

Screenshot (2312).png

For example, If the target record is "Canon i70", SQL code must select products names until the target product name that are 1 to 7.

"HP pro 400"
"AOC T96"
"HP 220"
"Canon 9000F"
"Dell 2330"
"AOC C23"
"EPSON 100"

I also tried this :
Code:
SELECT top DCount("ID","tbl_printers","ProductName = '" & Canon i70 & "') ProductName
FROM tbl_Printers;

But It didn't work.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 19:25
Joined
May 21, 2018
Messages
8,463
Code:
SELECT A.ProductName
FROM tbl_Printers as A
WHERE A.ID < (Select B.ID from tbl_Printers as B where ProductName = "Cano i70")
ORDER BY A.ID;
 

cheekybuddha

AWF VIP
Local time
Today, 23:25
Joined
Jul 21, 2014
Messages
2,237
Code:
SELECT
  t.ProductName
FROM tbl_Printers t
WHERE t.ID < (
  SELECT
    t2.ID
  FROM tbl_Printers t2
  WHERE t2.ProductName = 'Canon i70'
);
 

Users who are viewing this thread

Top Bottom