New topic: Problem with SQLite/REALSQLdatabase query
<http://forums.realsoftware.com/viewtopic.php?t=29665> Page 1 of 1 [ 7 posts ] Previous topic | Next topic Author Message tjones Post subject: Problem with SQLite/REALSQLdatabase queryPosted: Thu Aug 20, 2009 6:55 pm Joined: Wed May 24, 2006 5:54 pm Posts: 204 Hello, I'm trying to do a basic group by and count on my REALSQLdatabase database table, but I keep getting an error. The error I'm getting is "near "Select": syntax error" Code:Dim sqlSTR As String = "Select Result, count(*) as total From Results Where ridx = '1' group by Result" rs = db.SQLSelect(sqlSTR) What am I doing wrong? Thanks, tom Top dglass Post subject: Re: Problem with SQLite/REALSQLdatabase queryPosted: Thu Aug 20, 2009 7:04 pm Joined: Fri Sep 30, 2005 9:29 am Posts: 569 Location: California Using 'total' as the alias of your Count column probably. Top HMARROQUINC Post subject: Re: Problem with SQLite/REALSQLdatabase queryPosted: Fri Aug 21, 2009 1:01 am Joined: Sun Jan 25, 2009 5:11 pm Posts: 207 Do you own any SQL Administrator tools? If so: What happens when you run that query directly in SQL? I'm getting a leading space when I try your code. Where can that come from? Hector _________________ Windows Home Premium 64 bit SP1 / 4GB RAM Windows XP Pro SP3 / 2 GB RAM RealSoftware Santa Claus, pleas give me a grid! (Wish almost granted!!!) Top tjones Post subject: Re: Problem with SQLite/REALSQLdatabase queryPosted: Fri Aug 21, 2009 1:17 am Joined: Wed May 24, 2006 5:54 pm Posts: 204 If I copy the string right in to the GUI tool it works just fine. I did try changing the word total but that made no difference. I'm at a loss here. Top thommcgrath Post subject: Re: Problem with SQLite/REALSQLdatabase queryPosted: Fri Aug 21, 2009 2:34 am Site Admin Joined: Tue May 06, 2008 1:07 pm Posts: 242 Location: Greater Hartford Area, CT Have you tried removing that character from the beginning of the select? _________________ -- Thom McGrath IT Developer, REAL Software Top HMARROQUINC Post subject: Re: Problem with SQLite/REALSQLdatabase queryPosted: Fri Aug 21, 2009 10:32 am Joined: Sun Jan 25, 2009 5:11 pm Posts: 207 This works as soon as I uncomment the third line: Code:Dim sqlSTR As String sqlSTR = "Select Result, count(*) as total From Results Where ridx = '1' group by Result" 'sqlstr = right(sqlstr, len(sqlstr) -1) // Uncomment this line and it should =work EditField1.Text = sqlSTR Still wondering where the funky leading space/character comes from. Hector _________________ Windows Home Premium 64 bit SP1 / 4GB RAM Windows XP Pro SP3 / 2 GB RAM RealSoftware Santa Claus, pleas give me a grid! (Wish almost granted!!!) Top simonjohn Post subject: Re: Problem with SQLite/REALSQLdatabase queryPosted: Fri Aug 21, 2009 10:45 am Joined: Sat Apr 19, 2008 12:44 pm Posts: 187 Location: Dorset, UK Quote:Have you tried removing that character from the beginning of the select? Yes, what is that strange character? There is nothing wrong with the SQL: Code:Select Result, count(*) as total From Results Where ridx = '1' group by Result _________________ Simon Larkin QiSQL Database Solutions http://www.qisql.com Top Display posts from previous: All posts1 day7 days2 weeks1 month3 months6 months1 year Sort by AuthorPost timeSubject AscendingDescending Page 1 of 1 [ 7 posts ]
-- Over 1500 classes with 29000 functions in one REALbasic plug-in collection. The Monkeybread Software Realbasic Plugin v9.3. http://www.monkeybreadsoftware.de/realbasic/plugins.shtml [email protected]
