SQL UPPER not working - android

I have a table
And try to execute this command :
SELECT * FROM projects WHERE (UPPER(title) LIKE '%КУ%' OR UPPER(description) LIKE '%КУ%')
In the end i want to get a row with id 2 but nothing returns to me.
But, when i change request to :
SELECT * FROM projects WHERE (UPPER(title) LIKE '%Ку%' OR UPPER(description) LIKE '%Ку%')
It returns row (as expected) with id 2.
What i doing wrong? Why UPPER not worked?

The problem is in Russian language :) UPPER is working only for latin alphabet. There is question about it in ru.stackoverflow

Related

How to select only the rows that have a column with a repeated value?

I am building an Android app for a bus schedule between my village and Barcelona.
I have built a sqlite database as follows (probably it's a really bad design, but I'm a newbie in databases):
run | stopCode | time
1.........1.......620
1.........2.......650
.
.
.
5........11.......NULL
5........12.......1020
And so on.
I use the following SQL statement in order to pick the rows that match my criteria:
SELECT run,stopCode,time
FROM tablename
WHERE time> x AND time <>'' AND (stopCode=1 or stopCode=8);
Using this sentence gives me an output similar to this:
6(run)|8(stopCode)|1045(time)
9|1|1900
9|8|2000
My problem is that I want to select only the rows that have the run value repeated twice. If it only appears once, it means that the bus has a NULL destination in that particular run.
I tried using COUNT(*) c, blabla c=2, but that gives me only the second row with the repeated run number, and I want to select both of them (which would correspond to where you pick the bus and where you want to go down). Any clues how to do it?
Edit:
this is the statement i tried
SELECT run,stopNumber,time,COUNT(run) c
FROM Directes_dirBarna
WHERE time> 600 and time<>'' and (stopNumber=1 or stopNumber=8)
GROUP BY run having c=2;
Edit2:
Thanks to Marcos Vasconcelos i fixed it. This is my final statement if anyone has the same problem:
SELECT run,parada, hora FROM Directes_dirBarna taula WHERE hora> 600
and TIME<>'' IN (parada=1, parada=8);
Here you go:
select t1.run, t1.code, t2.code from tablename t1, tablename t2
where t1.run = t2.run and t1.code = 1 and t2.code = 8;
You select 2 rows (t1 and t2) such as they are on the same run, one is the departure, and one is the arrival. It will give you a single line for each run that satisfies the condition.
See http://sqlfiddle.com/#!5/7d3f3/3
I don't have enough reputations to add it as a comment. If I understand correctly what the question is, to select runs that are 5 or 8 and that should be more than once in the table with some constraints on time.
For that the solution is
SELECT a.run, a.stopNumber,time
FROM Directes_dirBarna a, Directes_dirBarna b
WHERE a.run = b.run AND (a.run= 5 or a.run = 8) AND time> 600 and time<>'';
remove (a.run= 5 or a.run = 8) if you want any run that repeated twice.
You can use the IN operator and repeat the query (but it would be bad if any other option is available)

Android: InputConnection - how to get composingtext correctly

I do backspace in textfield, and i need to set as composingText word or it part, that has left before cursor position. I must do that thing each time when i press backspace. So my step must be:
get size of last word (or part of it);
make it as composing text.
I try do it like this:
ic.setSelection(startWordPosition, word.length());
ic.setComposingText(word, 1);
All works good, while i don't test backspace in string like "a.a". It select all 3 characters, but when set, replace only part after dot.
Then i try make it like this:
ic.deleteSurroundingText(word.length(),0);
ic.setComposingText(word, 1);
But it not work correctly and delete sometimes text before my word(maybe because it currently compose).
Just find one more way that looks like right:
ic.finishComposingText();
ic.deleteSurroundingText(word.length(),0);
ic.setComposingText(word, 1);
ic.setSelection(fullInputedString.length(),fullInputedString.length());
Is it correct?
How should it be in right way?
target sdk=8
Thanks!
UPD:
I found next solution for
ic.finishComposingText();
ic.deleteSurroundingText(wordForInsert.length(), 0);
ic.setComposingText(wordForInsert, 1);
And for latest android version i use appropriate method:
ic.setComposingRegion();
But this solution provide issue in standatrd android browser for 4.0v Android and latest.

Check words from database

i am new to android development,so dint get me wrong. I am developing an application in which a text is generated.which is normally a word. The word is checked in a database for is corresponding value pair. Here the word is the key and its corresponding value is the value .
Since the text is auto generated it sometimes goes wrong(mis spelled). How do i perform a check of auto generated word to match with the mostly matched letters in the database of key word.
example: auto-generated word(key) - value
americ:
america : a country
Here the auto generatd word is americ(key) is not matched since it only contains america in its pair set.it need to be corrected as america.
You are probably using SQLite. Your best bet is soundex, which is desribed here.
Soundex has many shortcomings, but it might get you started. If you want a real measure, then go with Levenshtein distance, which is not built into the database (as far as I know).

android SearchableDictionary sample - suggesting words

i just used the searchabledictionary sample of android, which is available in samples folder of android sdk for windows. ( API level 9 )
i completed the definitions.txt file with the same format like
key - value
when i type a word in search area, the app tries to suggest words, but it doesn't find the exact word.here is an example. i searched the word test , and this is definitions.txt :
acceptance test - meaning
acid test - meaning
alpha test - meaning
benchmark tests - meaning
....
flight test - meaning
load test - meaning
....
test - meaning
it finds 15 first words of this list, ( hopefully it doesn't search words like attestaion) but it doesn't show the exact word test !
i read the DictionaryProvider and DictionaryDatabase but i could not realize the root of problem!
the question is how can i suggest the exact word test at first of the list?
Check Dictionary.java, you will see loadWords function.
That function opens definitions.txt file and iterates all lines, and splits every line with "-" and adds to a Hashmap dictionary.
And again in same file there is getMatches function, which takes your search keyword and gets result from dictionary.
Not sure but because when you are searching a suggestion, first couple of matches displays.
And because of "test" keyword exists on too many lines and ("test - meaning") is your last definition, you can't see on suggesting list.
You could try to move "test -meaning" line to the very first line on definitions.txt.

Delete one single cell from ContactsContract-ContentProvider

Hi fellow android programmers,
I wan't my application to delete one single information from a contact and I don't mean one phonenumber or one adress, I actually mean like only the street from the adress or only the job_description from the organization. Technically I won't to delete one cell of one row in the Data-Table of the ContactsContract-ContentProvider.
I red the documentation twice, but they are only talking about whole rows when they describe the insert-, update-, delete-, query-Methods :(
Is anyone aware of how to delete one particular cell? Or am I supposed to update one row with one cell so to "" (empty string)? Or do I even need to read one whole row, set the one cell to "" (empty string) and update the whole row?
Cheers and thanks in advance Ali3n
Do not delete it.. try to update it..
1) add your new value of particular column, like contentValues.put(STREET,"");
2) update the table by using update method. and use a where condition where contact_id = ur id.
PS:column names are not right.

Categories

Resources