sql-like

Trying to join Access tables with like statement with list in field

独自空忆成欢 提交于 2019-12-11 08:36:23
问题 I have a problem that I have been hunting for a solution to, but to avail. The basics are that I am trying to join 2 tables in Access by comparing a value in a field of Table 1 to a field in Table 2 that contains the number concatenated along with a few others in a list type format. (both fields are text type) Example. Table1.CWT value = 640242 Corresponding Table2.TAG_NO value I want to match to = 640242; 635894; 058426 So that it links the two tables based on the common value (640242 in

MYSQL Searching multiple tables with different columns using LIKE

坚强是说给别人听的谎言 提交于 2019-12-11 07:55:46
问题 I need to be able to do a search on multiple tables and return all parts that are similar to the searched term. My problem is that the tables have varying amounts of columns. They do have columns with similar names though. First the PHP checks the "productnumber" table to find all parts with the similar part number. Then it searches through each table to find a matching number. Right now if a similar part is found in the Components table, it will not display any parts found from Adapters or

LIKE query sql not working in concatenated values with space

混江龙づ霸主 提交于 2019-12-11 07:48:12
问题 I have this table ** -------------------------------------------------- | id | fname | lname | age -------------------------------------------------- | 1 | John | Smith | 20 ------------------------------------------------- | 2 | John Craig | Smith | 20 -------------------------------------------------- | 3 | John Shaw | Smith | 20 -------------------------------------------------- MYSQL QUERY: select id from person where concat(fname, lname) LIKE = '%johnsmith%' - this can select the id but

SQL WHERE string LIKE field

雨燕双飞 提交于 2019-12-11 07:37:00
问题 I have a table tracking links structured as follows: id domain_name traffic_count enabled created_at Let's say I have a record with domain_name of "some-domain.com", and then let's say I want to find the record having that domain, except all I have to go by is a subdomain of that domain. I essentially want to do this: SELECT * FROM links 'subdomain.some-domain.com' LIKE %domain_name%" How would I do this? 回答1: Updated (thanks to Chad Johnson): SELECT * FROM links WHERE 'subdomain.some-domain

SQL Server Performance tips for like %

这一生的挚爱 提交于 2019-12-11 06:58:02
问题 I have a table with 5-10 million records which has 2 fields example data Row Field1 Field2 ------------------ 1 0712334 072342344 2 06344534 083453454 3 06344534 0845645565 Given 2 variables variable1 : 0634453445645 variable2 : 08345345456756 I need to be able to query the table for best matches as fast as possible The above example would produce 1 record (e.g row 2) What would be the fastest way to query the database for matches? Note : the data and variables are always in this format (i.e

Rails SQL query on unknown (dynamic) number of queries using LIKE

随声附和 提交于 2019-12-11 06:56:10
问题 I have a Rails search form that performs a dynamic query. That is, the user enters a search like: (hobby="skiing") OR (gender="male" AND hobby="jogging") So, I don't know how many queries I will be searching by until runtime. I parse the search query by converting it into a valid SQL query, so the above search would be converted to the following format: query = "hobby LIKE ? OR (gender LIKE ? AND hobby LIKE ?)" queries = ["skiing", "male", "jogging"] For the following query: where(query,

Getting MySQL syntax error using CodeIgniter LIKE active record

左心房为你撑大大i 提交于 2019-12-11 06:55:39
问题 This is my code return $this->db ->select('organization') ->like('title',$this->db->escape_str($query)) ->or_like('description',$this->db->escape_str($query)) ->get('shop_search') ->num_rows(); every thing works well until there is a ' and NOT " in the $query . The error is: $query="d'" You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '%' OR `description` LIKE '%d\\\\\\'%'' at line 3 SELECT `organization`

Implementing a “like” operator multiple times in one Linq to Entities query

只谈情不闲聊 提交于 2019-12-11 04:36:46
问题 We have a list of strings and we need to filter our results by that list. Example would be find all students who have SSNs that start with 465, 496, or 497 (plus x more) List<string> list = GetPossibleStartsWithValues(); var qry = from student in entities.Students.WhereStartsWith(x=>x.SSN, list) select new SearchedStudent { Name = student.Name, SSN = student.SSN, ... } The code provided here is close to what we need, but we can't figure out how to impliment the StartsWith that we need using

How to use many LIKE operators and use index

寵の児 提交于 2019-12-11 02:54:10
问题 In my query I want find rows that match one of many LIKE operators. I know 3 ways of doing that but only one of them can use index. Lets start with table: CREATE TABLE dir ( id BIGSERIAL PRIMARY KEY, path TEXT NOT NULL ); CREATE INDEX path_idx ON dir(path TEXT_pattern_ops); After inserting sample data I can do: EXPLAIN ANALYZE SELECT id, path FROM dir WHERE path LIKE 'A%' OR path LIKE 'B%' OR path LIKE 'C%'; Above query use index correctly. Second way: EXPLAIN ANALYZE SELECT id, path FROM dir

Is there and alternative to LIKE statement in T-SQL?

怎甘沉沦 提交于 2019-12-11 02:31:42
问题 I have a scenario where I need to perform following operation: SELECT * FROM [dbo].[MyTable] WHERE [Url] LIKE '%<some url>%'; I have to use two % (wildcard characters) at the beginning and the end of Url ( '%<some url>%' ) as user should be able to search the complete url even if he types partial text. For example, if url is http://www.google.co.in and user types "goo", then the url must appear in search results. LIKE operator is causing performance issues. I need an alternative so that I can