I have some sql like

Select * 
from bti.table
where
field between start and stop
and field1 is null
and (field2 like 'HH%' or field2 like 'HS%' or field2 like 'SS%')

I only get results like HH%. What gives? Is there an alternate way to do this? I could make 3 separate queries and combine the results but that would be slow and clunky.

version is 16.0.0.2213

thanks

asked 29 Aug, 14:31

josephcraw's gravatar image

josephcraw
513
accept rate: 100%

edited 29 Aug, 15:16

I cannot reproduce that behavior. Please confirm the version and build you are testing. I tested the following query against the demo database:

select * from employees where StartDate between '1900-01-01' and '2019-01-10' and TerminationDate is null and (City like 'CH%' or City like 'CO%' or City like 'WA%')

In the results, I get the following cities: Charlottetown, Cornwall, Wakefield, Waterdown, and Waterloo

(29 Aug, 14:51) Chris Keating

version is 16.0.0.2213

(29 Aug, 15:16) josephcraw

I'm an idiot. The issue was there was nothing that met the criteria for the other likes. Sorry

permanent link

answered 29 Aug, 15:25

josephcraw's gravatar image

josephcraw
513
accept rate: 100%

1

Don't worry about it... you did the right thing by posting a question, sometimes that's the path to epiphany :)

(29 Aug, 16:11) Breck Carter
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×6

question asked: 29 Aug, 14:31

question was seen: 65 times

last updated: 29 Aug, 16:12