SQLite LIKE statement with special characters - sqlite

I am trying to run a search query on my SQLite db and am having problems with special characters that are stored.
I have a column called site_name which contains records like castle, chàteau, church. When someone uses chateau as their search term I want it to pull out the chàteau record.
Is there a method for handling this in SQLite?
Thanks

See here
The link references Android development, but it appears to answer your question.

Related

Ordering results (from a search) by number of matches

I'm implementing search for an Android app using an SQLite db, and am wanting to order the results from a search according to the number of matches in a TEXT column
For example let's say that my db table is called article, the TEXT column I want to search is called article_main_text, and that the the user searches for the word "friend". Then I want the db table rows which have the highest number of occurrences of "friend" in their article_main_text column to be shown first
I already know that I can provide custom SQLite statements in the sort order in my CursorLoader (for example supplying this to the CursorLoader constructor), so I'd like to ask: How can I write SQLite code that orders the results with the help of SQLite?
Counting just the occurrences of a word might not be the most accurate or most efficient way of doing it. What you really need is full text search. Which is supported in sqlite and available in Android.
Fortunately there is a tutorial on Android Developer and I am sure there would be a full working sample in their code collections.

Sqlite linked tables in Access give #deleted values, again

Situation: MS Access (happens to be 2010) using SQLite ODBC driver (0.997) to link to tables in a SQLite (3.x) database.
Problem: data values in all columns in all rows display as "#Deleted".
Solution: This is a "answer my own question" kind of post, with a solution, below.
Edited: to move solution to Answers section.
Earlier, I searched in stackoverflow, found a similar question (sqlite linked tables in Access give #deleted values) with a good answer that turns out to be inapplicable in my case. So I'm adding some info here.
Half of the problem is explained here: http://support.microsoft.com/kb/128809 '"#Deleted" errors with linked ODBC tables.'
The above link was no longer available in Jul-2021. However you may find a good explanation for '#DELETED# Records Reported by Access' in https://dev.mysql.com/doc/connector-odbc/en/connector-odbc-errors.html
This explains that Access (Jet) wants a table to have a unique index in order to be able to insert/update the table if necessary.
If your SQLite table doesn't have a unique index (or primary key), then Access will only allow read access to the table -- you can't edit the table's data in Access, but the data displays fine.
To make the table updateable you might revise your SQLite code (or using a SQLite tool) to add an index to the table.
If your PK/unique index happens to use a TEXT field, that's fine for SQLite. However, when you link to it in Access, Access will show the #Deleted indications.
The chain of events appears to be:
Access/Jet notices the unique index, and tries to use it. However, SQLite TEXT fields are variable length and possibly BLOBs. This apparently doesn't fulfill Access's requirements for a unique index field, hence the #Delete indication.
To avoid that problem, the index has to be a SQLite field type that Access will accept. I don't know the complete list of types that are acceptable, but INTEGER works.
Hope this helps someone.

Using html5sql to create a sqlite database and retrieve records

Based on this question HTML5SQL retrieve records from web databases using SELECT statements, i used the code from "http://html5sql.com" site to create and retrieve records from the database in my Android mobile Phone. In fact i used this method "$.get('demo-statements.sql',function(sql)" to create the database where in the "demo-statements.sql" file was the sql code to create the tables and insert the records in the database. The problem is when i use Greek characters in my phone i see rhombus with a questionmark inside the rhombus instead of the Greek characters.
Any idea why is that?
Thanks for help
Well i cleaned up the chrome's database and i noticed that the same problem came up when i run it on Chrome. When i use programmers tools and i click on Resources tab to see the database, the tables and the records i see the same characters. So when i console.log the HTML which creates the page i see also the strange characters...
Before use the "$.get('demo-statements.sql',function(sql)" method and wrote the sql code directly in Dreamweaver the characters where OK!

Searching a column with comma separated values

I have SQL server 2008 r2 edition, which am working on and a .Net webpage as front end.
Coming to the issue, there is a column in the database which basically consists of various skill sets separated by a comma. For example some candidate has a 3 different skill sets namely C#, SQL server, Oracle. The user who wants to list the candidates having the skills of both C# and Oracle will provide the input as C#, Oracle in a text box on the webpage. I want to write a query which can list out such. I have tried freetext search. But it fails to fetch if in Capital/small words, no support for wildcard character, even the order of skills.
Below is the sample query
Select * from profiles where freetext(skills, ‘C#,Oracle’)
From my POV the correct (and unwelcome) answer is to redesign your table structure: You should never ever have a list of values in a single field, IF YOU WANT TO ACCESS THEM SEPARATELY.
DISCLAIMER: I agree with #EugenRieck (+1 to that answer) - stuffing a CSV string in one field is bad design.
But if you must...look here first. Or try a CLR solution.
this is a good one about full-text.
Match Both C# and Oracle
select * From Profiles where contains(*,'"Oracle" and "C#"')
Match Either C# or Oracle
select * From Profiles where contains(*,'"Oracle" or "C#"')

Find Unique Words in One or More Columns?

I'm looking at implementing tags in my ASP.NET website. After looking at several algorithms, I'm leaning towards having a couple of database columns that contain one or more tag words. I will then use full-text search to locate rows with specified tags.
All of this seems pretty straight forward except for one thing: I need to be able to generate a list of available tags, which the user can select from.
I know I can write a C# program to build the list of available tags, and then run it once every week or so, but I was just wondering if there's any SQL-method for doing stuff like this more efficiently.
Also, I can't help but notice that the words will be extracted anyway as part of building the full-text index. I don't suppose there's any way to access that information?
This isn't how I'd choose to structure this but to answer the actual question...
In SQL Server 2008 you can query the sys.dm_fts_index_keywords and sys.dm_fts_index_keywords_by_document table valued functions to get the information that you want.
Why not to use separate table for tags with many-to-many relationship with tagged items table?
I mean something like that:
--Articles
ArticleId
Text
--Tags
TagId
Name
--TagsToArticles
ArticleRef
TagRef

Resources