Notice: Any messages purporting to come from this site telling you that your password has expired, or that you need to verify your details, confirm your email, resolve issues, making threats, or asking for money, are
spam. We do not email users with any such messages. If you have lost your password you can obtain a new one by using the
password reset link.
Due to spam on this forum, all posts now need moderator approval.
Entire forum
➜ MUSHclient
➜ Lua
➜ SQLite and variables
It is now over 60 days since the last post. This thread is closed.
Refresh page
Posted by
| Marcopolo
(3 posts) Bio
|
Date
| Sat 27 Mar 2010 04:59 AM (UTC) |
Message
| Hi, I'm not very familiar with Lua's SQL interface(or SQL for that matter), but I was wondering if there was a way to get a value from a row/column without having to iterate over a table to store it into a variable? Similar to accessing a value directly in a table i.e. myvalue = table['atable']['btable']['something']?
At the moment i'm using nrows. It seems to me, that if I knew what I was looking for, using nrows would be inefficient to put things into variables with.
Thanks. | Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #1 on Sat 27 Mar 2010 07:21 AM (UTC) |
Message
| The whole idea of SQL is to store large amounts of data (eg. a telephone directory) and then get small bits back (eg. the phone number for "Marcopolo") by doing a SELECT statement that limits the amount that is returned.
If you narrow down your search enough (eg. if you look up a player, the player names are unique, and you search by player name) then you should only ever need to get one row.
|
- Nick Gammon
www.gammon.com.au, www.mushclient.com | Top |
|
Posted by
| Marcopolo
(3 posts) Bio
|
Date
| Reply #2 on Sat 27 Mar 2010 08:51 AM (UTC) |
Message
| I think what I really meant to ask was how I would go about putting the result of a select statement into a variable without dealing with a table?
At the moment I do this:
for a in db:nrows([[SELECT timestamp FROM trade WHERE area = ']]..currentzone..[[']]) do
last_update=a["timestamp"]
end
Is this the only way to put a single field of information into a variable? Do all results from a select statement end up being a table?
| Top |
|
Posted by
| Nick Gammon
Australia (23,133 posts) Bio
Forum Administrator |
Date
| Reply #3 on Sun 28 Mar 2010 04:37 AM (UTC) |
Message
| |
The dates and times for posts above are shown in Universal Co-ordinated Time (UTC).
To show them in your local time you can join the forum, and then set the 'time correction' field in your profile to the number of hours difference between your location and UTC time.
13,947 views.
It is now over 60 days since the last post. This thread is closed.
Refresh page
top