1

I used DB Browser for SQLite version 3.6.0; SQLite Version 3.8.9. This application already supports Regular Expression out of box (sqlitebrowser). I can use regexp on column brand but failed on column revision;

For example

SELECT brand,revision FROM TDevice where TDevice.brand regexp '^ASUS$'

and the result is 114 Rows returned from: SELECT brand,revision FROM TDevice WHERE TDevice.brand regexp '^ASUS$'; (took 51ms)


However, if regexp is applied on different column, then I get the error

SELECT brand,revision FROM TDevice WHERE TDevice.revision regexp '^ASUS$';

and the error message is invalid operand: SELECT brand,revision FROM TDevice WHERE TDevice.revision regexp '^ASUS$';


Both brand and revision are of TEXT type. The table creation schema is as below:

CREATE TABLE `TDevice` (
`id`    INTEGER NOT NULL,
`brand` varchar(128) NOT NULL,
`model` varchar(128) NOT NULL,
`revision`  TEXT,
PRIMARY KEY(id)
);
MikimotoH
  • 393
  • 1
  • 4
  • 16

2 Answers2

0

Both brand and revision are of TEXT type. The table creation schema is as below:

No They are different see your table description correctly if you change the TEXT to varchar it will work fine.

Or I will check and inform you how to use regex or can we use regex with TEXT datatype.

or you can convert(CAST) your TEXT to varchar and can perform the match operations

See this post for how to CAST TEXT into varchar Need to convert Text field to Varchar temporarily so that I can pass to a stored procedure

Community
  • 1
  • 1
smali
  • 4,687
  • 7
  • 38
  • 60
0

The difference between brand and revision is that brand cannot accept NULL text. After I fill the revision with empty string '':

UPDATE TDevice SET revision='' WHERE revision IS NULL

, this invalid operand error is resolved.

MikimotoH
  • 393
  • 1
  • 4
  • 16