Viktor Apoyan
Viktor Apoyan

Reputation: 10755

Search in SQLite database

Problem Description

I have SQLite database, in which I keep some information, one of the columns keep information about company name, it can be formatted like this "This is a new company" or "Google Inc" or "New company of USA" or "USA base company". Now I want to write a query which will search through the database and give all items which words starts with search word.

For example if I search USA word

it must search database and find all words in the sentence which start with USA

Upvotes: 1

Views: 7138

Answers (2)

Alexis C.
Alexis C.

Reputation: 93902

Get the input of the user and then just do a query like :

SELECT * FROM Company
WHERE company_name like 'USA%';

You will have just to replace USA by the user's input.

EDIT :

If you want to find all compagnies where the compagny_name contains USA just do :

SELECT * FROM Company
    WHERE company_name like '%USA%';

Upvotes: 4

harsh
harsh

Reputation: 7692

It would be typical sql syntax (for all rows where information column values starts with USA):

select * from table where information like 'USA%'

Upvotes: 2

Related Questions