Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 5 of 5 total
Thread Search parameters and wildcards
Thu, May 23 2019 5:58 AMPermanent Link

Matthew Jones

I can do a

SELECT * FROM Table WHERE field LIKE '%'

and that will probably find multiple rows yes? Exact syntax doesn't matter, it's possible.

How about

SELECT * FROM Table WHERE field LIKE :PARAM

Does the Param stop the use of "wildcards", or can the user pass in a '%' and match everything?

What about

SELECT * FROM Table WHERE field = '%'

Does that match wildcards, or just the rows with that exact symbol?

I ask because I am sort of going to depend on this, and don't want someone to set their new value to % or something and cause havoc.

--

Matthew Jones
Thu, May 23 2019 8:52 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Matthew

>SELECT * FROM Table WHERE field LIKE '%'
>
>and that will probably find multiple rows yes? Exact syntax doesn't matter, it's possible.

Apart from being mental and using that construct rather than "SELECT * FROM Table" yes

>How about
>
>SELECT * FROM Table WHERE field LIKE :PARAM
>
>Does the Param stop the use of "wildcards", or can the user pass in a '%' and match everything?

You can pass in a % - ame comment as to mental stability applies Smiley

>
>What about
>
>SELECT * FROM Table WHERE field = '%'
>
>Does that match wildcards, or just the rows with that exact symbol?

The latter -  "=" does not do wildcards. However, I'd ban users from having % in fields wherever possible.

If you do use % as part of a text field then according to the manual you can escape the character eg

select * from companies where _name LIKE '20/%' ESCAPE '/'

but it doesn't seem to work here on my ansi database, but

select * from companies where _name LIKE '20/%%' ESCAPE '/'

_name was set to "20%"

does.

I'll be interested in Tim's opinion on this.

Roy

Thu, May 23 2019 9:06 AMPermanent Link

Matthew Jones

Roy Lambert wrote:

> The latter -  "=" does not do wildcards. However, I'd ban users from having % in fields wherever possible.

That's the key, and in fact the code I grabbed does a SELECT first, and then edits the first item and updates that. So turns out that it won't affect more than one item even if you do a %, but I wanted to be sure of where I was.

As you say, I should exclude a % anyway. It isn't a useful thing in people's names...

--

Matthew Jones
Fri, May 24 2019 2:26 AMPermanent Link

Roy Lambert

NLH Associates

Team Elevate Team Elevate

Matthew


>As you say, I should exclude a % anyway. It isn't a useful thing in people's names...

I'm a science fiction fan and it seems fairly common in a lot of books I read Smiley

Roy
Sat, May 25 2019 1:45 PMPermanent Link

Tim Young [Elevate Software]

Elevate Software, Inc.

Avatar

Email timyoung@elevatesoft.com

Roy,

<< but it doesn't seem to work here on my ansi database, but

select * from companies where _name LIKE '20/%%' ESCAPE '/' >>

This is a bug - when the escaped character is the last character in the pattern string, it fails.

I've fixed this for 2.31 B5, which is building right now.

Tim Young
Elevate Software
www.elevatesoft.com
Image