Register forum user name Search FAQ

Gammon Forum

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 ➜ General ➜ sqlite question

sqlite question

It is now over 60 days since the last post. This thread is closed.     Refresh page


Posted by Graymane   USA  (14 posts)  Bio
Date Sun 13 Jul 2014 05:01 PM (UTC)
Message
I have a bit of sql where I query for some room details below. The issue I have is that the name of room 3314 happens to be NULL. In the lua version, the query below fails. If I run the same query in sqlite, I get the single row back correctly with a NULL r.name. How can I get this to work in lua with the NULL value? If I put something in the name column, the lua version starts working.


-- lua mushclient version:

local sql = "SELECT r.name, r.area_id, a.name AS area_name FROM ROOMS r JOIN AREAS a ON a.id = r.area_id WHERE r.id = 3314;"

for name, area_id, area_name in self.db:urows (sql) do
print ("WORKED")
end

--[[
sqlite3 version:
SELECT r.name, r.area_id, a.name AS area_name FROM ROOMS r JOIN AREAS a ON a.id = r.area_id WHERE r.id = 3314;
--]]
Top

Posted by Nick Gammon   Australia  (23,133 posts)  Bio   Forum Administrator
Date Reply #1 on Sun 13 Jul 2014 08:38 PM (UTC)
Message
Personally I use db:rows rather than db:urows, then I get a table back and if a column was NULL I get nil in that table entry.

- Nick Gammon

www.gammon.com.au, www.mushclient.com
Top

Posted by Graymane   USA  (14 posts)  Bio
Date Reply #2 on Sun 13 Jul 2014 09:13 PM (UTC)
Message
Thanks
Top

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.


9,899 views.

It is now over 60 days since the last post. This thread is closed.     Refresh page

Go to topic:           Search the forum


[Go to top] top

Information and images on this site are licensed under the Creative Commons Attribution 3.0 Australia License unless stated otherwise.