0

I have 5 users in my database I want to get the first 3 data and send them a specific email. How can I get the remaining 2 users and sent them on another set of email

$sql = $conn->prepare('SELECT * FROM Users LIMIT 3');
$sql->execute();
while($result = $sql->fetch(PDO::FETCH_ASSOC)) {
     mail sending codes...
}

DB: Users

id | Name | Email
1  | John | john@gmail.com 
2  | Mark | mark@gmail.com 
3  | Erik | erik@gmail.com 
4  | Ryan | ryan@gmail.com 
5  | Grey | grey@gmail.com 
Dharman
  • 30,962
  • 25
  • 85
  • 135
Jay
  • 37
  • 1
  • 6

2 Answers2

0

the first 3

SELECT * FROM Users LIMIT 3

the next 2 users

SELECT * FROM Users OFFSET 3
Mike Foxtech
  • 1,633
  • 1
  • 6
  • 7
0

Please read this about OFFSET

SELECT Email FROM Users OFFSET 3

OFFSET skips a specific number (in this case 3) of rows.

Jakob
  • 1,858
  • 2
  • 15
  • 26