How do I get the rowID of all records found using Count(*) WHERE…
How do I get the rowID of all records found using Count(*) WHERE…
How do I get the rowID of all records found using Count(*) FROM member WHERE lastname = '" + lname + "'")
http://www.oldtimeradiotoday.com - Listen to or download classic old time radio broadcasts.
Re: How do I get the rowID of all records found using Count(*) WHERE…
select [ColumnName, ...] from [table] where [filters]
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
Re: How do I get the rowID of all records found using Count(*) WHERE…
I'm not sure how I should code that to get the rowid of each record found.select [ColumnName, ...] from [table] where [filters]
I tried this:
Code: Select all
lname = "Zorro"
DatabaseQuery(#dbaseID, "SELECT count(*) FROM member Where lastname = '"+ lname +"'")
NextDatabaseRow(#dbaseID)
maxRec = Val(GetDatabaseString(#dbaseID, 0))
http://www.oldtimeradiotoday.com - Listen to or download classic old time radio broadcasts.
Re: How do I get the rowID of all records found using Count(*) WHERE…
without "count"
the created table must be have a rowID as primary key ...
the created table must be have a rowID as primary key ...
My Projects ThreadToGUI / OOP-BaseClass / EventDesigner V3
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
PB v3.30 / v5.75 - OS Mac Mini OSX 10.xx - VM Window Pro / Linux Ubuntu
Downloads on my Webspace / OneDrive
- captain_skank
- Enthusiast
- Posts: 636
- Joined: Fri Oct 06, 2006 3:57 pm
- Location: England
Re: How do I get the rowID of all records found using Count(*) WHERE…
I may have misunderstood your first post, but using COUNT() will not return the ID no's - only the total number of records returned.
E.G would return a single number ( being the total number of records meeting the specified criteria )
I assume your table has a column named ID so the query would look something like
So your code would be something like ( I added a counter to display total records as well ) :
E.G
Code: Select all
SELECT Count(*) FROM member WHERE lastname = '" + lname + "'"
I assume your table has a column named ID so the query would look something like
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
Re: How do I get the rowID of all records found using Count(*) WHERE…
Thank you very much. I'll give that a try.
Cheers!
Cheers!
http://www.oldtimeradiotoday.com - Listen to or download classic old time radio broadcasts.
Re: How do I get the rowID of all records found using Count(*) WHERE…
Thank you again captain_skank. That works fine.
http://www.oldtimeradiotoday.com - Listen to or download classic old time radio broadcasts.