Jump to content

SQL : get a value from a column


Cocodrilo

Recommended Posts

How to get a string value from a column db? something like this:

local q = dbQuery(con, "SELECT * FROM t_ayuntamiento WHERE Cuenta=?",Cuenta) 
local result = dbPoll(q,-1) 
     
if tostring(result) == "Cocodrilo" then 
    outputChatBox(result.. " is into db") 
end 

Link to comment
you can either loop;
for key, value in ipairs (result) do  
    outputChatBox(value.Cocodrilo.. " is into db") 
end 
  

or use the column name as lua index;

outputChatBox (result[1].Cocodrilo.. "is into db")  

I'll recommend to you to use the second method as it's fastest than the first one.

Link to comment

I'll recommend to you to use the second method as it's fastest than the first one.

local q = dbQuery(con, "SELECT * FROM t_ayuntamiento WHERE Cuenta=?",Cuenta) 
local result = dbPoll(q,-1) 
local data = result[1] --Define result[1] with data instead of repeating it everytime needed. 
outputChatBox (data.Cocodrilo.. "is into db") 

Link to comment

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...