Click here to Skip to main content
15,902,938 members
Home / Discussions / Database
   

Database

 
GeneralRe: Problem sending email to group Pin
Danpeking16-Jul-18 22:42
Danpeking16-Jul-18 22:42 
QuestionReport server moved from one server to another server Pin
VK1910-Jul-18 8:04
VK1910-Jul-18 8:04 
QuestionSSIS Best Practice Regarding Storage Pin
#realJSOP27-Jun-18 3:52
professional#realJSOP27-Jun-18 3:52 
AnswerRe: SSIS Best Practice Regarding Storage Pin
Jörgen Andersson2-Jul-18 21:16
professionalJörgen Andersson2-Jul-18 21:16 
AnswerRe: SSIS Best Practice Regarding Storage Pin
Eddy Vluggen2-Jul-18 23:19
professionalEddy Vluggen2-Jul-18 23:19 
GeneralRe: SSIS Best Practice Regarding Storage Pin
#realJSOP3-Jul-18 3:08
professional#realJSOP3-Jul-18 3:08 
GeneralRe: SSIS Best Practice Regarding Storage Pin
Eddy Vluggen3-Jul-18 3:30
professionalEddy Vluggen3-Jul-18 3:30 
GeneralRe: SSIS Best Practice Regarding Storage Pin
#realJSOP3-Jul-18 5:13
professional#realJSOP3-Jul-18 5:13 
GeneralRe: SSIS Best Practice Regarding Storage Pin
Eddy Vluggen3-Jul-18 5:30
professionalEddy Vluggen3-Jul-18 5:30 
GeneralRe: SSIS Best Practice Regarding Storage Pin
#realJSOP3-Jul-18 5:43
professional#realJSOP3-Jul-18 5:43 
GeneralRe: SSIS Best Practice Regarding Storage Pin
Eddy Vluggen3-Jul-18 8:43
professionalEddy Vluggen3-Jul-18 8:43 
QuestionSSMS 2016 and SQL Server 2008R2 Pin
#realJSOP26-Jun-18 23:31
professional#realJSOP26-Jun-18 23:31 
AnswerRe: SSMS 2016 and SQL Server 2008R2 Pin
Eddy Vluggen26-Jun-18 23:50
professionalEddy Vluggen26-Jun-18 23:50 
AnswerRe: SSMS 2016 and SQL Server 2008R2 Pin
Victor Nijegorodov27-Jun-18 1:07
Victor Nijegorodov27-Jun-18 1:07 
AnswerRe: SSMS 2016 and SQL Server 2008R2 Pin
Richard Deeming27-Jun-18 1:35
mveRichard Deeming27-Jun-18 1:35 
GeneralRe: SSMS 2016 and SQL Server 2008R2 Pin
#realJSOP27-Jun-18 2:46
professional#realJSOP27-Jun-18 2:46 
QuestionSQL Server Agent Monitoring Pin
#realJSOP26-Jun-18 1:48
professional#realJSOP26-Jun-18 1:48 
QuestionCheck for object existence sql server 2012 is creating stored procedure as dynamic sql Pin
indian14325-Jun-18 10:36
indian14325-Jun-18 10:36 
AnswerRe: Check for object existence sql server 2012 is creating stored procedure as dynamic sql Pin
Richard Deeming26-Jun-18 1:50
mveRichard Deeming26-Jun-18 1:50 
QuestionPDO/mySQL/PHP - when is it OK to NOT use parameter binding, when should I REALLY use it? Pin
needAbreakNow17-Jun-18 16:13
needAbreakNow17-Jun-18 16:13 
AnswerRe: PDO/mySQL/PHP - when is it OK to NOT use parameter binding, when should I REALLY use it? Pin
Jörgen Andersson17-Jun-18 19:29
professionalJörgen Andersson17-Jun-18 19:29 
AnswerRe: PDO/mySQL/PHP - when is it OK to NOT use parameter binding, when should I REALLY use it? Pin
Mycroft Holmes17-Jun-18 20:43
professionalMycroft Holmes17-Jun-18 20:43 
AnswerRe: PDO/mySQL/PHP - when is it OK to NOT use parameter binding, when should I REALLY use it? Pin
Eddy Vluggen18-Jun-18 0:27
professionalEddy Vluggen18-Jun-18 0:27 
AnswerRe: PDO/mySQL/PHP - when is it OK to NOT use parameter binding, when should I REALLY use it? Pin
jschell23-Jun-18 5:12
jschell23-Jun-18 5:12 
QuestionPDO Get Previous and Next Record partially working Pin
needAbreakNow16-Jun-18 21:19
needAbreakNow16-Jun-18 21:19 
I'm trying to fetch the previous and next record using PDO/MYSQL. The SQL code for Next fetches the next record, but for Previous always returns the first record. Don't understand why Previous does not work. There are 7 records in this test set and the 'article_id' field is not contiguous (due to deletions) but is broken up as such: 24, 45,46,47, 48, 50, 51. Code below:

PHP
$id = 47;
echo 'current id is:'.$id;
//GET PREVIOUS ID
$stmt= $db->prepare("SELECT * FROM blog WHERE article_id<$id LIMIT 0,1");
$stmt->execute();
$row=$stmt->fetch(PDO::FETCH_ASSOC);
echo '<br>';
echo 'Previous ID is:'.$row['article_id'];
//GET NEXT ID
$stmt= $db->prepare("SELECT * FROM blog WHERE article_id>$id LIMIT 0,1");
$stmt->execute();
$row=$stmt->fetch(PDO::FETCH_ASSOC);
echo '<br>';
echo 'Next ID is:'.$row['article_id'];

The resultant output is:
PHP
current id is:47
Previous ID is:24
Next ID is:48

The previous ID should be 46, not 24!

I've tried the same SQL in phpMyAdmin directly and it still returns 24 for the previous, but works fine for the next. I've seen many other examples on the web showing the similar code as I have, but theirs seems to work (via youtube), mine doesn't. Any help would be appreciated!
Thanks in advance.

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.