简体   繁体   中英

How do I build this simple mySQL query?

I would like to select all rows where field A is 'x' and field B is one of 'w', 'y' or 'z'. A and B are both strings, and I would like case to be ignored.

SELECT *
  FROM table
 WHERE LOWER(A) = 'x'
   AND LOWER(B) IN ('w', 'y', 'z')
select * from tablename where LCASE(A) ='x' and LCASE(B) in('w','y','z')

I would like to select all rows where field A is 'x' and field B is one of 'w', 'y' or 'z'

... WHERE fldA = "x" AND fldB IN ("w", "y", "z") ...

A and B are both strings, and I would like case to be ignored.

Just make sure that columns' collations are set to case insensitive type, eg utf8_unicode_ci , utf8_german_ci , latin2_general_ci (the suffix _ci is the key).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM