sql-like

How to search millions of record in SQL table faster?

时光怂恿深爱的人放手 提交于 2019-12-03 02:16:44
I have SQL table with millions of domain name. But now when I search for let's say SELECT * FROM tblDomainResults WHERE domainName LIKE '%lifeis%' It takes more than 10 minutes to get the results. I tried indexing but that didn't help. What is the best way to store this millions of record and easily access these information in short period of time? There are about 50 million records and 5 column so far. Most likely, you tried a traditional index which cannot be used to optimize LIKE queries unless the pattern begins with a fixed string (e.g. 'lifeis%'). What you need for your query is a full

LINQ to SQL - select where text like string array

萝らか妹 提交于 2019-12-03 00:29:53
I have a List <string > of variable count, and I want to query (via LINQ) a table to find any items that contain any of those strings in the Text column. Tried this (doesn't work): items = from dbt in database.Items where (stringList.FindAll(s => dbt.Text.Contains(s)).Count > 0) select dbt; Query would be something like: select * from items where text like '%string1%' or text like '%string2%' Is this possible? Check this article out to do what you want: http://www.albahari.com/nutshell/predicatebuilder.aspx This works like a dream. I essentially cut and pasted their code and got this back

SQL SELECT LIKE (Insensitive casing)

风流意气都作罢 提交于 2019-12-02 21:39:20
I am trying to execute the sql query: select * from table where column like '%value%'; But the data is saved as 'Value' ( V is capital ). When I execute this query i don't get any rows. How do i make the call such that, it looks for 'value' irrespective of the casing of the characters ? use LOWER Function in both (column and search word(s)). Doing it so, you assure that the even if in the query is something like %VaLuE%, it wont matter select qt.* from query_table qt where LOWER(column_name) LIKE LOWER('%vAlUe%'); If you want this column be case insensitive : ALTER TABLE `schema`.`table`

MYSQL PHP - get float LIKE $float

半腔热情 提交于 2019-12-02 20:31:55
问题 I want to get rows with floats like my $float . I used this code: $float = $_GET['float']; $requst = mysql_fetch_array(mysql_query("SELECT * FROM floats WHERE float LIKE'$float.%%%%%%%'")); then I echoed all the rows with while: while ($r = $request) { echo $a['float']; } but the page doesn't show anything. (YES, I typed in the address bar ?float=34 and there are floats like 34.****** in the table.) What is the problem? (PHP version 5.2, MYSQL version 5.0) 回答1: Try This $requst = mysql_query(

SQLite: Should LIKE 'searchstr%' use an index?

浪子不回头ぞ 提交于 2019-12-02 18:14:11
I have a DB with several fields word_id — INTEGER PRIMARY_KEY word — TEXT ... ..and ~150k rows. Since this is a dictionary, I'm searching for a word with mask 'search_string%' using LIKE. It used to work just fine, taking 15ms to find matching rows. The table has an index for a field 'word' . Recently I've modified the table (some fields of that table which are out of the scope) and something happened — it's taking 400ms to execute query, so I understand that as it fails to use index now. Straightforward query with = instead of like shows 10ms result. Does someone have an idea what's happening

Ruby on Rails - search in database based on a query

▼魔方 西西 提交于 2019-12-02 18:13:38
问题 I have a simple form, where I set up a query that I want to browse, for example panasonic viera . This is on how I search the term in database: Product.where("name ilike ?", "%#{params[:q]}%").order('price') The query looks like %panasonic viera% , but I would need to search the query this way: %panasonic%viera% - I need to find all products, where is in the title the word panasonic or viera ... but how to make this query? 回答1: One solution would be to break up your query into individual

'LIKE' clause with 'AND' operator in SQL Server 2012

∥☆過路亽.° 提交于 2019-12-02 17:19:51
问题 I have exactly the same requirement as in this thread. How to use JOIN LIKE with AND Operator in SQL Server? I have been clueless despite searching the net for hours. I have a table 'Filter' with column 'Value' and 2 records in it as 'Value1' and 'Value2' as varchar values. Select * From MasterTable Inner Join Filter ON MasterTable.Name LIKE '%' + Filter.Value + '%' This query means: Select * From MasterTable Where MasterTable.Name LIKE '%Value1%' OR MasterTable.Name LIKE '%Value2%' Now how

Empty string variable matching to LIKE conditions in SQL

醉酒当歌 提交于 2019-12-02 14:53:13
问题 I have a SQL Server table containing a nvarchar(max) column. I ran a query to select every row where this column contains the string 'remove'. Amongst the results, I have several rows where this column is populated with an empty string and I don't understand why these values have been returned. I tried to investigate further, on one of the empty string values returned. I found that the empty string value would match to certain LIKE conditions, but not others. For instance, it will match to '

two words and blank spaces not working in MYSQL query using LIKE

可紊 提交于 2019-12-02 10:39:27
i'm making a searcher for my site and this works fine with one word querys $consulta = mysql_query("SELECT * FROM recetas WHERE (titulo LIKE '%$busqueda%' OR intro LIKE '%$busqueda%' OR extra LIKE '%$busqueda%') ORDER BY id DESC"); But if i type 'two words' it doesn't give me result, $busqueda it's result from a <input/> given through $_POST['TERM'] any idea what i'm missing? SOLVED i was missing to encode the variable to URI... oops haha THANKS! Think of how your query will look at the end: Select ... where '%two words%. ... If you want to search for words like that, you'll have to massage

'LIKE' clause with 'AND' operator in SQL Server 2012

二次信任 提交于 2019-12-02 09:57:24
I have exactly the same requirement as in this thread. How to use JOIN LIKE with AND Operator in SQL Server? I have been clueless despite searching the net for hours. I have a table 'Filter' with column 'Value' and 2 records in it as 'Value1' and 'Value2' as varchar values. Select * From MasterTable Inner Join Filter ON MasterTable.Name LIKE '%' + Filter.Value + '%' This query means: Select * From MasterTable Where MasterTable.Name LIKE '%Value1%' OR MasterTable.Name LIKE '%Value2%' Now how can I change JOIN LIKE that means AND not OR? Something like: Select * From MasterTable Where