SQLite assistance

Hey, I’m using a for loop to go through a bunch of groups that are stored in a table in the file sv.db. The problem is that I don’t know how to go through all of the groups properly. If someone could give me some assistance that would be great.

	groups = sql.Query("SELECT * FROM prop_groups")
	for k,v in pairs(groups) do
		if ply:IsUserGroup( sql.QueryValue("SELECT * FROM prop_groups") ) then
			return true

If you need anything more just ask.

What do you think this line is doing

if ply:IsUserGroup( sql.QueryValue("SELECT * FROM prop_groups") ) then

As you may not know sql.QueryValue gets the first record in the table, so what that does is get the first group and run it against all the players twice. Because there are currently two groups inside the table

a) It’s shitcode because you’re calling it in a loop.
b) Do you even know which column QueryValue returns? Because you’re pointlessly selecting all of them.
c) You’re doing a loop but doing fuck all with key and value variables it provides.
d) I still don’t understand what you’re trying to do.

your first query returns the entire result set as an array of tables. its not like the sqlite c api where you only have a result cursor and have to call a function to fetch the current row.

this is all sql.QueryValue does:
[Lua]function sql.QueryValue(q)
local row = sql.Query(q)[1]
local k, v = next(row)
return v

you may find this enlightening:
[Lua]PrintTable(sql.Query(“SELECT * FROM prop_groups”))[/lua]