views:

23

answers:

1

Lets say I have a table with columns A , B , C , D and I want to do a match on column A and C

I see that you can either match a single column or all column in sqlite ie

- match column A
select * from table where A match 'cat' 

- match all columns
select * from table where table match 'cat'

Is it possible to match only columns A and C? If not, how do you guys get around this?

Thanks for your suggestion!

A: 

You can concatenate columns using the || operator:

SELECT * FROM table WHERE a || b MATCH 'cat'

I'm not sure about the MATCH function in SQLite though, I think it will usually throw an exception (see http://www.sqlite.org/lang_expr.html#match).

faxi05
No, sqlite doesnt seem to like that, although you can return concatenate column ie select a || b from table where a match 'cat'
Unikorn
What's the operator precedence here? Match or ||? Try some parentheses.
MPelletier
actually, I noticed that you can do something like this: select * from table where table match 'colA:cat OR colB:cat' , but the performance is horrible as compare to having colA and colB in one column and do a match against it.
Unikorn