How do I get the rowID of all records found using Count(*) WHERE…
Posted: Sun Jun 13, 2021 9:52 pm
How do I get the rowID of all records found using Count(*) FROM member WHERE lastname = '" + lname + "'")
http://www.purebasic.com
https://www.purebasic.fr/english/
I'm not sure how I should code that to get the rowid of each record found.select [ColumnName, ...] from [table] where [filters]
Code: Select all
lname = "Zorro"
DatabaseQuery(#dbaseID, "SELECT count(*) FROM member Where lastname = '"+ lname +"'")
NextDatabaseRow(#dbaseID)
maxRec = Val(GetDatabaseString(#dbaseID, 0))
Code: Select all
SELECT Count(*) FROM member WHERE lastname = '" + lname + "'"
Code: Select all
SELECT ID FROM member WHERE lastname = '" + lname + "'"
Code: Select all
; N.B : assumes you have opened a database connection using 0 as it's ID.
LVAR_sql = "SELECT ID FROM member WHERE lastname = '" + lname + "'"
LVAR_count.i = 0
If DatabaseQuery(0, LVAR_sql)
While NextDatabaseRow(0)
LVAR_data.s = GetDatabaseString(0, 0)
debug LVAR_data
LVAR_count + 1
Wend
debug "Total records = " + str(LVAR_count)
FinishDatabaseQuery(0)
Else
LVAR_msg.s = "D A T A B A S E E R R O R" + #CRLF$ + #CRLF$
LVAR_msg + LVAR_sql + #CRLF$ + #CRLF$
LVAR_msg + "This SQL failed"
Debug LVAR_msg
EndIf