I have a database column that contains text in CSV format. A sample cell looks like this:
Audi,Ford,Chevy,BMW,Toyota
I'd like to generate a query that matches any column with the string 'BMW'. How can I do this in SQL?
You can declare a VARCHAR(10) and SQLite will be happy to store a 500-million character string there. And it will keep all 500-million characters intact. Your content is never truncated. SQLite understands the column type of "VARCHAR(N)" to be the same as "TEXT", regardless of the value of N.
Some Differences Between VARCHAR and TEXT The VAR in VARCHAR means that you can set the max size to anything between 1 and 65,535. TEXT fields have a fixed max size of 65,535 characters. A VARCHAR can be part of an index whereas a TEXT field requires you to specify a prefix length, which can be part of an index.
SQLite provides two wildcards for constructing patterns. They are percent sign % and underscore _ : The percent sign % wildcard matches any sequence of zero or more characters. The underscore _ wildcard matches any single character.
You can use wildcard characters: %
select * from table
where name like '%BMW%'
I think you are looking for something like
SELECT * FROM Table
WHERE Column LIKE '%BMW%'
the % are wildcards for the LIKE statement.
More information can be found HERE
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With