sql-like

How do you force mysql LIKE to be case sensitive? [duplicate]

自古美人都是妖i 提交于 2019-11-27 17:34:30
Possible Duplicate: Mysql Like Case Sensitive Mysql ignores case for its LIKE comparisons. How can you force it to perform case-sensitive LIKE comparisons? Use LIKE BINARY : mysql> SELECT 'abc' LIKE 'ABC'; -> 1 mysql> SELECT 'abc' LIKE BINARY 'ABC'; -> 0 John Woo Another alternative is to use COLLATE , SELECT * FROM table1 WHERE columnName like 'a%' COLLATE utf8_bin; SQLFiddle Demo 来源: https://stackoverflow.com/questions/14007450/how-do-you-force-mysql-like-to-be-case-sensitive

SQL Server search using like while ignoring blank spaces

点点圈 提交于 2019-11-27 16:29:28
I have a phone column in the database, and the records contain unwanted spaces on the right. I tried to use trim and replace, but it didn't return the correct results. If I use phone like '%2581254%' it returns customerid ----------- 33470 33472 33473 33474 but I need use percent sign or wild card in the beginning only, I want to match the left side only. So if I use it like this phone like '%2581254' I get nothing, because of the spaces on the right! So I tried to use trim and replace, and I get one result only LTRIM(RTRIM(phone)) LIKE '%2581254' returns customerid ----------- 33474 Note that

What is the best way to search the Long datatype within an Oracle database?

放肆的年华 提交于 2019-11-27 15:05:33
问题 I am working with an Oracle database that stores HTML as a Long datatype. I would like to query the database to search for a specific string within the HTML data stored in the Long. I tried, "select * from TABLE where COLUMN like '%form%'". This causes the following Oracle error because "like" is not supported for Long datatypes. ORA-00932: inconsistent datatypes: expected NUMBER got LONG 回答1: You can use this example without using temp table: DECLARE l_var VARCHAR2(32767); -- max length

Create hive table using “as select” or “like” and also specify delimiter

风格不统一 提交于 2019-11-27 13:26:43
问题 Is it possible to do a create table <mytable> as select <query statement> using row format delimited fields terminated by '|'; or to do a create table <mytable> like <other_table> row format delimited fields terminated by '|'; The Language Manual seems to indicate not.. but something tickles me I had achieved this in the past. 回答1: Create Table as select (CTAS) is possible in Hive. You can try out below command: CREATE TABLE new_test row format delimited fields terminated by '|' STORED AS

Match only entire words with LIKE?

半腔热情 提交于 2019-11-27 13:12:25
So 'awesome document' LIKE '%doc%' is true, because doc is a sub-string. But, I want it to be false while 'awesome doc' or 'doc awesome' or 'awesome doc awesome' should be true. How can I do with with a like? I'm using sqlite, so I hope I don't have to use something that isn't available. How about split it into four parts - [MyColumn] Like '% doc %' OR [MyColumn] Like '% doc' OR [MyColumn] Like 'doc %' OR [MyColumn] = 'doc' Edit: An alternate approach (only for ascii chars) could be: '#'+[MyColumn]+'#' like '%[^a-z0-9]doc[^a-z0-9]%' (You may want to take care of any special char as well) It

Element or class LIKE selector for jQuery?

送分小仙女□ 提交于 2019-11-27 10:36:14
For whatever reason I have these classes called .main_sub1 , .main_sub2 etc. Never mind why I can't have .main .sub . Is there a way with jQuery, sort of in the way it is possible to do with attributes, to get the classes containing main ? Tatu Ulmanen Using $("[class^=main]") will select all elements whose classname starts with 'main'. Take a look at jQuery docs about selectors , there are a lot of other variations you can use, for example: [class*=main] will select elements whose classname contains 'main' [class~=main] will select elements whose classname has the word 'main' (delimited with

What is Full Text Search vs LIKE

我的未来我决定 提交于 2019-11-27 10:01:50
I just read a post mentioning "full text search" in SQL. I was just wondering what the difference between FTS and LIKE are. I did read a couple of articles but couldn't find anything that explained it well. erickson In general, there is a tradeoff between "precision" and "recall". High precision means that fewer irrelevant results are presented (no false positives), while high recall means that fewer relevant results are missing (no false negatives). Using the LIKE operator gives you 100% precision with no concessions for recall. A full text search facility gives you a lot of flexibility to

Python String Formats with SQL Wildcards and LIKE

这一生的挚爱 提交于 2019-11-27 09:12:11
I'm having a hard time getting some sql in python to correctly go through MySQLdb. It's pythons string formatting that is killing me. My sql statement is using the LIKE keyword with wildcards. I've tried a number of different things in Python. The problem is once I get one of them working, there's a line of code in MySQLdb that burps on string format. Attempt 1: "SELECT tag.userId, count(user.id) as totalRows FROM user INNER JOIN tag ON user.id = tag.userId WHERE user.username LIKE '%%s%'" % (query) This is a no go. I get value error: ValueError: unsupported format character ''' (0x27) at

Escaping wildcards in LIKE

喜夏-厌秋 提交于 2019-11-27 08:46:40
问题 How do I escape wildcards ( _ and % ) when using a SQL LIKE operator in Oracle? I came to a silly issue today. I need to search for the presence of an underscore _ on a varchar column using LIKE . It doesn't work -- as expected -- since underscores are wildcards according to SQL. Here's my (simpified) code: create table property ( name varchar(20), value varchar(50) ); insert into property (name, value) values ('port', '8120'); insert into property (name, value) values ('max_width', '90');

SQL LIKE with no wildcards the same as '='?

♀尐吖头ヾ 提交于 2019-11-27 07:43:05
问题 I know this is a pretty basic question, and I think I know the answer...but I'd like to confirm. Are these queries truly equivalent? SELECT * FROM FOO WHERE BAR LIKE 'X' SELECT * FROM FOO WHERE BAR ='X' Perhaps there is a performance overhead in using like with no wild cards? I have an app that optionally uses LIKE & wild cards. The SP currently does the like and appends the wild cards -- I am thinking of just updating the query to use like but have the app append the wild cards as needed.