[Gambas-user] How to write sql query in gambas way

bb adamnt42 at gmail.com
Tue May 10 11:54:43 CEST 2022


On Tue, 2022-05-10 at 14:18 +0930, bb wrote:
> On Tue, 2022-05-10 at 09:02 +0545, Safiur Rahman wrote:
> > Hi
> > 
> > That cannot be the answer. The array can be of variable count and
> > count may
> > go to twenty or thirty.
> > 
> > On Mon, 9 May 2022, 21:40 Safiur Rahman, <isafiur at gmail.com> wrote:
> > 
> > > Hi
> > > 
> > > I get result when I execute the following query:
> > > 
> > > Dim res As Result
> > >   res = conn.Exec("select fldtitle from tbltest where
> > > flddepartment
> > > in('Austria','Azerbaijan')")
> > > 
> > > But I don't get result when I execute the following query:
> > > res = conn.Exec("select fldtitle from tbltest where flddepartment
> > > in &1",
> > > ["Austria", "Azerbaijan"])
> > > 
> > > How can I write this query properly in gambas passing an array
> > > argument?
> > > 
> > > (Attached a project to demonstrate)
> > > 
> > > --
> > > Regards
> > > Safiur Rahman
> > > 
> > 
> > ----[ http://gambaswiki.org/wiki/doc/netiquette ]----
> Hint. Try using db.debug=true. You should see then why your code is
> not
> doing what youe think.
> b 
Oh and by the way. I have often found that letting the dbms working out
"IN" clauses by itself is often much more efficient than intervening
and producing the in-list.
(I haven't executed your code but quite often constructs like

	conn.Exec("SELECT x,y,z FROM a where a.thing in (SELECT thing
FROM things t WHERE t.date = current_date))

are much quicker than "doing it yourself".)

b
 



More information about the User mailing list