Click here to Skip to main content
15,894,825 members
Home / Discussions / Database
   

Database

 
QuestionSQLite Thread Safety Pin
Richard Andrew x6410-Nov-23 12:23
professionalRichard Andrew x6410-Nov-23 12:23 
AnswerRe: SQLite Thread Safety Pin
Gerry Schmitz10-Nov-23 14:04
mveGerry Schmitz10-Nov-23 14:04 
GeneralRe: SQLite Thread Safety Pin
Richard Andrew x6410-Nov-23 15:33
professionalRichard Andrew x6410-Nov-23 15:33 
GeneralRe: SQLite Thread Safety Pin
Gerry Schmitz13-Nov-23 11:14
mveGerry Schmitz13-Nov-23 11:14 
AnswerRe: SQLite Thread Safety Pin
Jörgen Andersson12-Nov-23 21:16
professionalJörgen Andersson12-Nov-23 21:16 
QuestionSQLite syntax error that I can't figure out - SOLVED Pin
Richard Andrew x644-Nov-23 14:09
professionalRichard Andrew x644-Nov-23 14:09 
AnswerRe: SQLite syntax error that I can't figure out Pin
k50544-Nov-23 17:22
mvek50544-Nov-23 17:22 
GeneralRe: SQLite syntax error that I can't figure out Pin
Richard Andrew x645-Nov-23 1:57
professionalRichard Andrew x645-Nov-23 1:57 
Questionplease Pin
daw htikehtike21-Oct-23 19:17
daw htikehtike21-Oct-23 19:17 
AnswerRe: please Pin
Richard MacCutchan21-Oct-23 21:14
mveRichard MacCutchan21-Oct-23 21:14 
AnswerRe: please Pin
jschell23-Oct-23 5:25
jschell23-Oct-23 5:25 
AnswerRe: please Pin
Gerry Schmitz24-Oct-23 7:15
mveGerry Schmitz24-Oct-23 7:15 
AnswerRe: please Pin
CHill6029-Oct-23 23:44
mveCHill6029-Oct-23 23:44 
QuestionGetting Last Record and First Record from a Record Set (SQL server DB) Pin
Member 1184335621-Sep-23 8:07
Member 1184335621-Sep-23 8:07 
I am pretty new using MS SQL. I perform a query over some SQL server table; it returns a record set; but I need to read the last record just to get the value of a certain column.

This is my procedure:
PHP
$connectionInfo = array( "Database"=>$myDB, "UID"=>$myUser , "PWD"=>$myPass);
$conn = sqlsrv_connect( $myServer, $connectionInfo);

$query = "SELECT * FROM( SELECT col0, col1, col2, col3 FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1 LEFT JOIN t3 ON t1.col2 = t3.col2) AS t ORDER BY t.col0; ";
$rec_set = sqlsrv_query($connection, $query, array(), array("Scrollable" => 'buffered'));

if( $rec_set === false ) die( print_r( sqlsrv_errors(), true));  

$connectionInfo = array( "Database"=>$myDB,  UID"=>$myUser , "PWD"=>$myPass);
$conn = sqlsrv_connect( $myServer, connectionInfo);

$query = "SELECT * FROM( SELECT col0, col1, col2, col3 FROM t1 LEFT JOIN t2 ON t1.col1 = t2.col1 LEFT JOIN t3 ON t1.col2 = t3.col2) AS t ORDER BY t.col0; ";

$rec_set = sqlsrv_query($connection, $query, array(),  array("Scrollable" => 'buffered'));
if( $rec_set === false ) die( print_r( sqlsrv_errors(), true));	
			 
$row_count = sqlsrv_num_rows($rec_set);
if ($row_count === false) die( print_r( sqlsrv_errors(), true));

$reg   = sqlsrv_fetch_array( $rec_set, SQLSRV_FETCH_ASSOC, 0);
$first = $reg['column_name'];

$reg   = sqlsrv_fetch_array( $rec_set, SQLSRV_FETCH_ASSOC, $row_count - 1);
$last  = $reg['column_name'];


It is clear that the sqlsrv_fetch_array DOES NOT work like that. Does anyone know how to achieve my goal, that is, getting last and first records from that record set without generating another SELECT?
Thank you in advance.
AnswerRe: Getting Last Record and First Record from a Record Set (SQL server DB) Pin
Richard Andrew x6421-Sep-23 8:58
professionalRichard Andrew x6421-Sep-23 8:58 
GeneralRe: Getting Last Record and First Record from a Record Set (SQL server DB) Pin
Member 1184335621-Sep-23 9:18
Member 1184335621-Sep-23 9:18 
GeneralRe: Getting Last Record and First Record from a Record Set (SQL server DB) Pin
Gerry Schmitz21-Sep-23 14:02
mveGerry Schmitz21-Sep-23 14:02 
Questionprior action plan to prevent sql database corruption Pin
Kar_Malay1-Sep-23 20:01
Kar_Malay1-Sep-23 20:01 
AnswerRe: prior action plan to prevent sql database corruption Pin
Richard Andrew x642-Sep-23 2:38
professionalRichard Andrew x642-Sep-23 2:38 
GeneralRe: prior action plan to prevent sql database corruption Pin
Dave Kreskowiak2-Sep-23 3:33
mveDave Kreskowiak2-Sep-23 3:33 
AnswerRe: prior action plan to prevent sql database corruption Pin
jschell4-Sep-23 5:42
jschell4-Sep-23 5:42 
GeneralRe: prior action plan to prevent sql database corruption Pin
Kar_Malay2-Oct-23 9:22
Kar_Malay2-Oct-23 9:22 
QuestionFetch row and display in frontend column Pin
Kesiena26-Aug-23 3:14
Kesiena26-Aug-23 3:14 
AnswerRe: Fetch row and display in frontend column Pin
David Mujica28-Aug-23 3:16
David Mujica28-Aug-23 3:16 
AnswerRe: Fetch row and display in frontend column Pin
jschell29-Aug-23 5:01
jschell29-Aug-23 5:01 

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.