Re: [sqlite] select * where abc like "xxx" works, ...where abc='xxx' fails

2019-06-03 Thread Keith Medcalf

>Why does the "=" query fail and the "like" query work? There are no
>wildcards involved.

>The behavior is the same in Sqlite command line. There are no
>wildcards involved.

sqlite> create table songfiletable (
   ...> songfile_id integer primary key,
   ...> dancename text
   ...> );
sqlite> insert into songfiletable (dancename) values ('Waltz');
sqlite> select * from songfiletable where dancename like 'Waltz';
1|Waltz
sqlite> select * from songfiletable where dancename = 'Waltz';
1|Waltz

Works for me.  Perhaps your database does not contain what you believe it does 
... or you have some indexes on dancename that you are not disclosing

---
The fact that there's a Highway to Hell but only a Stairway to Heaven says a 
lot about anticipated traffic volume.


>-Original Message-
>From: sqlite-users [mailto:sqlite-users-
>boun...@mailinglists.sqlite.org] On Behalf Of Doug
>Sent: Monday, 3 June, 2019 17:47
>To: sqlite-users@mailinglists.sqlite.org
>Subject: [sqlite] select * where abc like "xxx" works, ...where
>abc='xxx' fails
>
>I am using Sqlite under QT 5.12.0.
>
>
>
>
>
>
>I create the table this way:
>
>
>
>QString sqlcreate = QLatin1String(
>
>  "CREATE TABLE songfiletable ("
>
>"songfile_id INTEGER PRIMARY KEY,"
>
>"dancename TEXT"
>
>  ");"  );
>
>
>
>I populated the table this way with dancename=QLatin1String("Waltz"):
>
>
>
>QString sqlinsert = QLatin1String(
>
>"INSERT INTO songfiletable ("
>
>"dancename"
>
>") VALUES(?);");
>
>  queryinsert.prepare(sqlinsert);
>
>  queryinsert.addBindValue(dancename.toUtf8());
>
>
>
>The query that works for dancename="Waltz" is this (with 'like'):
>
>QByteArray dn = d->dance_name.toUtf8();
>
>QByteArray filter = "(dancename like '" + dn + "')";
>
>
>
>The query that fails for dancename="Waltz" is this:
>
>QByteArray dn = d->dance_name.toUtf8();
>
>QByteArray filter = "(dancename='" + dn + "')";
>
>
>
>
>
>
>I have simplified the table and the queries to a single column for
>this message. The actual table has 22 columns.
>
>
>
>Why does the "=" query fail and the "like" query work?
>
>
>
>Regards, Doug
>
>
>
>
>
>___
>sqlite-users mailing list
>sqlite-users@mailinglists.sqlite.org
>http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users



___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


Re: [sqlite] select * where abc like "xxx" works, ...where abc='xxx' fails

2019-06-03 Thread Simon Slavin
On 4 Jun 2019, at 12:46am, Doug  wrote:

> Why does the "=" query fail and the "like" query work? 

To help us investigate ...

Which version of SQLite is this ?  You can use

SELECT sqlite_version();

to find out.

What do you mean by 'work' and 'fail' ?  Are you referring to an error code ?

Can you add a debug line to your code so that just before applying the filter 
it outputs the same text to a log ?  Just to check whether '.toUtf8()' does 
what you think it's doing.
___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users


[sqlite] select * where abc like "xxx" works, ...where abc='xxx' fails

2019-06-03 Thread Doug
I am using Sqlite under QT 5.12.0. 

 

Why does the "=" query fail and the "like" query work? There are no
wildcards involved.

 

I create the table this way:

 

QString sqlcreate = QLatin1String(

  "CREATE TABLE songfiletable ("

"songfile_id INTEGER PRIMARY KEY,"

"dancename TEXT"

  ");"  );

 

I populated the table this way with dancename=QLatin1String("Waltz"):

 

QString sqlinsert = QLatin1String(

"INSERT INTO songfiletable ("

"dancename"

") VALUES(?);");

  queryinsert.prepare(sqlinsert);

  queryinsert.addBindValue(dancename.toUtf8());

 

The query that works for dancename="Waltz" is this (with 'like'):

QByteArray dn = d->dance_name.toUtf8();

QByteArray filter = "(dancename like '" + dn + "')";

 

The query that fails for dancename="Waltz" is this:

QByteArray dn = d->dance_name.toUtf8();

QByteArray filter = "(dancename='" + dn + "')";

 

The behavior is the same in Sqlite command line. There are no
wildcards involved.

 

I have simplified the table and the queries to a single column for
this message. The actual table has 22 columns.

 

Why does the "=" query fail and the "like" query work? 

 

Regards, Doug

 

 

___
sqlite-users mailing list
sqlite-users@mailinglists.sqlite.org
http://mailinglists.sqlite.org/cgi-bin/mailman/listinfo/sqlite-users