mysql - C# SQL Query Multiple LIKE -


currently i'm making something.

using (var idatabasequery = lightningbolt.getdatabasemanager().createqueryobject())         {             idatabasequery.setquery("select * catalogue_baseitems name '%hc2_%' or name '%hc3_';");             data = idatabasequery.fetchtable();         } 

that's use, want items beginning hc2_ , hc3_, however, items starting hc2_. in sql contains items starting hc3_ doesn't show while executing query. wrong?

if want items beginning hc2_ or hc3_, need make 2 changes:

  1. don't use % @ beginning, and
  2. escape underscore because masks "any 1 character"

try this:

select * catalogue_baseitems name 'hc2\_%' or name 'hc3\_%' 

note %hc2_% match of following examples:

  • abchc2x (because of leading % , underscore match x)
  • hc23 (because underscore match 3)
  • ... , on

Comments

Popular posts from this blog

linux - xterm copying to CLIPBOARD using copy-selection causes automatic updating of CLIPBOARD upon mouse selection -

c++ - qgraphicsview horizontal scrolling always has a vertical delta -