ihudson Posted January 26, 2013 Share Posted January 26, 2013 I'm just learning sqlite3 forgive me if my concepts are not right, anyway I'm trying to add two variables to a SELECT statement:The variables would be $start and $end that the user would choose from a Combobox. The database holds 1 table (Distances) that has the distances between two locations ($start and $end).In the code that follows (if possible) how can I place $start where "Midlothian MS" is and $end where "School Board" is in the Select statement? I've tried several types of concatenation but no joy.Here is the schema:CREATE TABLE fulldata (id integer primary key autoincrement, Start text,End text,Distance integer);_SQLite_Startup() ConsoleWrite("_SQLite_LibVersion=" & _SQLite_LibVersion() & @CRLF) _SQLite_Open('distance.db') ; open Database _SQLite_QuerySingleRow(-1, "SELECT distance FROM fulldata WHERE Start = 'Midlothian MS' AND End = 'School Board';", $aRow) _SQLite_Close() _SQLite_Shutdown() While 1 $nMsg = GUIGetMsg() Switch $nMsg Case $GUI_EVENT_CLOSE Exit Case $Button1 MsgBox(0, "The distance is:",$aRow[0]) Case $Button2 _ArrayToClip($aRow, 0) ;send result to clipboard EndSwitch WEndThanks for your help,ihudson Link to comment Share on other sites More sharing options...
kylomas Posted January 26, 2013 Share Posted January 26, 2013 ihudson, Something like this should work _SQLite_QuerySingleRow(-1, "SELECT distance FROM fulldata WHERE Start = '" & $start & "' AND End = '" & $end & "';", $aRow) kylomas Forum Rules Procedure for posting code "I like pigs. Dogs look up to us. Cats look down on us. Pigs treat us as equals." - Sir Winston Churchill Link to comment Share on other sites More sharing options...
jchd Posted January 26, 2013 Share Posted January 26, 2013 (edited) Safer version: _SQLite_QuerySingleRow(-1, "SELECT distance FROM fulldata WHERE Start = " & _SQLite_FastEscape($start) & " AND End = " & _SQLite_FastEscape($end) & ";", $aRow) Edited January 27, 2013 by jchd This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
MvGulik Posted January 26, 2013 Share Posted January 26, 2013 (edited) _SQLiteFastEscape() _SQLite_FastEscape()[edit: fixed.] Edited January 27, 2013 by MvGulik "Straight_and_Crooked_Thinking" : A "classic guide to ferreting out untruths, half-truths, and other distortions of facts in political and social discussions.""The Secrets of Quantum Physics" : New and excellent 2 part documentary on Quantum Physics by Jim Al-Khalili. (Dec 2014) "Believing what you know ain't so" ... Knock Knock ... Link to comment Share on other sites More sharing options...
jchd Posted January 27, 2013 Share Posted January 27, 2013 Correct, thanks. This wonderful site allows debugging and testing regular expressions (many flavors available). An absolute must have in your bookmarks.Another excellent RegExp tutorial. Don't forget downloading your copy of up-to-date pcretest.exe and pcregrep.exe hereRegExp tutorial: enough to get startedPCRE v8.33 regexp documentation latest available release and currently implemented in AutoIt beta. SQLitespeed is another feature-rich premier SQLite manager (includes import/export). Well worth a try.SQLite Expert (freeware Personal Edition or payware Pro version) is a very useful SQLite database manager.An excellent eBook covering almost every aspect of SQLite3: a must-read for anyone doing serious work.SQL tutorial (covers "generic" SQL, but most of it applies to SQLite as well)A work-in-progress SQLite3 tutorial. Don't miss other LxyzTHW pages!SQLite official website with full documentation (may be newer than the SQLite library that comes standard with AutoIt) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now