FAQ Database Discussion Community


How To Use The Where & Like Operator Together in SQL?

sql,ms-access,where,like
I want to display a List of Instructors with only first name and last name, from Georgia and whose last name ends in ‘son’. I have written this so far: SELECT firstname, lastname, state FROM instructors WHERE state = 'ga' AND lastname LIKE '%son' But it is not returning the...

combine Not In and like function in mysql query

mysql,like,in-operator
I want to know is there there a way to merge not in() function with like or wildcard * in MySQL? Like in the following query: select sl_tags from tablname where `sl_tags` not in ('%Soccer%','%Football%','%Hockey%','%shinny%','%Basketball%','%Volleyball%','%Cricket%') the above query does not work. I know this works select sl_tags from tablname where...

Socialization likes

ruby-on-rails,ruby-on-rails-4,gem,like
I start to use Socialization gem. So, created User model with devise: class User < ActiveRecord::Base has_many :posts devise :database_authenticatable, :registerable, :recoverable, :rememberable, :trackable, :validatable acts_as_follower acts_as_followable acts_as_liker end Then I created Post with scaffold: class Post < ActiveRecord::Base belongs_to :user acts_as_likeable end And I want to allow user like...

SQL MATCH LIKE, make the id equal to each other

mysql,sql,match,like
so i have this code SELECT NAME, ingredient_id FROM ingredient_aliases WHERE (NAME) LIKE '%WATER%' it shows me all the similar names to WATER From image above, all three are Water. I have a lot of WATER names with NULL ingredient_id. Is there a way i can make their ingredient_id equal...

Non sensitive search in SORM with PostgreSQL

regex,postgresql,like,sorm
How to do non sensitive search in database using SORM and PostgreSQL? I tried whereLike: DB.query[User].whereLike("fullname", "%" + term + "%").fetch() This performs a case sensitive search. PostreSQL supports ILIKE operator, but didn't find ILIKE function in SORM DSL API. I tried with whereRegex too: DB.query[User].whereRegex("fullname", term).fetch() This returns an...

How to query using LIKE clause in mysql using vb.net comparing to a varied string input?

mysql,sql,vb.net,like,clause
I've search and tried a lot of procedure but did not work. CREATE PROCEDURE did not work, SET @variable is not acceptable and a couple more codes. This is my last "query" code that still didn't work. qry = "select * from employeefile where empfname LIKE '%''" + input +...

SQL Like filtering

sql,sql-server,tsql,like,varchar
Welcome! I am currently working on some C# and I encountered a rather silly issue. I need to fill ListBox with some data from database obviously. Problem is varchar filtering. I need to filter codes and display only the right ones. Example of codes are: RRTT, RRTR, RT12, RQ00, R100,...

MYSQL - Selecting rows with more than 1 LIKE

search,mysqli,like
My problem here is that, I want to create a simple search engine. I've got it to work by using 2 queries. The first one searches for the full search term and the second one searches for all of the matches word by word. For example if You search for...

Unable to like media in instagram from any access token

instagram,like,access-token,instagram-api
Since 3 or 4 days ago i'm not able to like any photos from any token, I think they blocked me to like. I still can follow/unfollow users via my application. I also can like photos via instagram iOS app. This is the error i have: "meta": { "error_type":"APINotAllowedError", "code":...

PHP like button(counter) inside a table

php,html,mysql,button,like
I have a table made in php and inside that table I show some content from my database. I have created a simple button (similar to like) in every td and I want it to increase by 1 with every hit. Here is the line with the button : echo...

MySQL: WHERE status NOT LIKE 'example%' isn't returning results with NULL status

mysql,null,like
I have a table that looks like the following: +---------+----------+-----------------+ | name | age | status | +---------+----------+-----------------+ | Clark | 25 | Example | +---------+----------+-----------------+ | Peter | 28 | Example2 | +---------+----------+-----------------+ | Waldo | 37 | NULL | +---------+----------+-----------------+ | Tarzan | 31 | Unknown | +---------+----------+-----------------+...

SQL Query: LIKE x% [duplicate]

sql,sql-server,like
This question already has an answer here: How do I escape a percentage sign in T-SQL? 3 answers I have a problem with my SQL Query and I would kindly ask for help. I have rows like: 2% 20% a 20% b a 2 b a 2% b etc....

Android SQLite Like query

sqlite,search,like
The following Query works Fine in my app db.query(true, DATABASE_TABLE, new String[] {KEY_ROWID,KEY_FAULTREF,KEY_WORKNUM,KEY_ORIGNUM,KEY_REPBY,KEY_REPDATTIM,KEY_DESCRIPTION}, KEY_FAULTREF + "='" + strname+ "'", null,null, null, null, null); strname is what I am searching for but it will only bring back records that EXACTLY match this I want to modify so it brings back everything...

query two tables where one row is like another row

mysql,select,like,mysql-5.6
I need to join two tables where one row value should be inside the other row. t1 f1,f2 t2 f11,f22 query select * from t1 join t2 on f1=f11 where f22 LIKE %f2% How do I write this?...

SQL find same value on multiple filelds with like operator

mysql,sql,search,like,sql-like
I have this records from my users table: user_id first_name last_name gender email ******* ********** ********* ****** ***** 229 Natalie Fern F [email protected] and I want to search same First Name & Last Name from first_name OR last_name. I have created sql query but not getting record. SELECT * FROM...

Code equivalent of “%[^ ]%” to Teradata

like,teradata
if @gl_cst_ctr_cde not like "%[^ ]%" Hi guys, Above is a Sybase code and would like to know the Teradata equivalent of not like "%[^ ]%" Many Thanks!...

OR Query mongodb from java with “like” and “line break” and “case insensitive” at the same time

java,mongodb,like,line-breaks,case-insensitive
This is sample of one document in my mongodb collection page_link_titles: { "_id" : ObjectId("553b11f30b81511d64152416"), "id" : 36470831, "linkTitles" : [ "Syrian civil war", "Damascus", "Geographic coordinate system", "Bashar al-Assad", "Al Jazeera English", "Free Syrian Army", ... "February 2012 Aleppo bombings", "2012 Deir ez-Zor bombing", "Aleppo University bombings" ] }...

Call to a member function fetch() on a non-object in

php,mysql,pdo,like
I'm trying to make a select in php with pdo. It's working with a lot of req but not when I'm using a like, example : Query: SELECT * FROM projets WHERE `identifiantProjetRattachement` LIKE "%PC13287%" ORDER BY "identifiantProjetDSR" This is my php code : <?php function requette($requette,$table) { $bdd =...

Mention more than one coloumn in where cause

sql,where,like
I want to do search in my app. Here is a general look of my query SELECT * FROM My_Table WHERE Col1 OR col or Col3 LIKE "String"; My question is what is the correct syntax for that query. Thanks....

How to use reverse like in oracle?

sql,oracle,like
Assume that these are records in a table: id code -------------- 1 75 2 90 3 901 4 9014 5 90145 6 80 What is the best query to get below result with 90145 value in where clause: id code -------------- 2 90 3 901 4 9014 5 90145 ...

SQL Multiple LIKE Statements

sql,sql-server,tsql,variables,like
I'm currently working on a report that shows me all post codes covered by our sales team. Each team covers over 100 post codes. What i would like to do is create a report that brings back the clients within the post code. Currently my code looks like this. SELECT...

OleDbConnection to MS Access: SQL query like clause with escape characters and wildcards

c#,ms-access,like,oledbconnection
There must be some very obvious answer but i just can not see it nor find solution from web. I try to count from db table how many rows contains file path LIKE "path". In Access Settings-table I have rows where path field (short text type) containing string: \\server\dir\something\ I...

SQL using Count, with same “Like” multiple times in same cell

sql,oracle,count,cell,like
I'm trying to get a count on how many times BNxxxx has been commented in the comments cell. So far, I can make each cell be counted once, but there may be multiple comments in a cell containing BNxxxx. For example, this: ------- BN0012 ------- BN0012 ------- BN0012 BN0123 -------...

oracle sql 'like' to find a specific substring

sql,oracle,like
Using oracle sql, I want to find a text containing, for example, the exact word 'SAN' or its plural if any. So my attempt was this: select * from table a where upper(a.text_field) like '%SAN%' But one of the results from the query was any text containing 'san' such as:...

Syntax for DAO 'Like' Select Query

sql,vba,like,dao
I'm sorry for bothering you all for what is probably a really simple problem. I use DAO Select queries fairly frequently but have never needed to filter using 'Like' based on a form field. The attached code, which should filter based on a combobox (comboRes), throws up a Syntax error...

Using codeigniter like query with wildcard

php,codeigniter,like
I'm trying to use a like query on Codeigniter. The function escapes my percent sign % to \%. My query is: SELECT * FROM (`invoices_rent`) WHERE `clerk_name` = 'BEAUTY' AND `date` LIKE '\%/\%/\%' $this->db->like('date', $date, 'none'); What can I do to prevent the percent sign getting escaped? I'm trying to...

Order result with LIKE operator

sql,sql-server,where,like
In SQL Server, I can use this SQL statement: SELECT * FROM Customers WHERE Country LIKE '%land%'; This query will return values that contains string land. Is it possible to sort returned values by position of string land? Example: Input values : "New Zealand, USA, Landcountry, Alandia" Output values :...

SQL with variable in LIKE statement: Invalid column Index

sql,oracle,variables,like,setstring
I'm using Oracle. PreparedStatement pstmt = con.prepareStatement("SELECT * FROM BookLoanInfo WHERE title LIKE '%?%' ORDER BY bid"); ResultSet rs; String bookstring = scan.nextLine(); try{ pstmt.clearParameters(); pstmt.setString(1, bookstring); rs = pstmt.executeQuery(); The actual problem seems to be with either the setString or how I have typed the query. This however gives...

Joining tables in query with no common fields

sql,select,join,inner-join,like
I am creating a database for a library with the following four tables. Table 1 - book isbn title author 111-2-33-444444-5 Pro JavaFX Dave Smith 222-3-44-555555-6 Oracle Systems Kate Roberts 333-4-55-666666-7 Expert jQuery Mike Smith Table 2 - copy code isbn duration 1011 111-2-33-444444-5 21 1012 111-2-33-444444-5 14 1013 111-2-33-444444-5...

How to match a string using a list of characters in SQLite

regex,sqlite,like
i have a problem working with SQLite especially like statement. I want to retrieve data from a table where a varchar column is composed of list of characters given by the user. For example: If the user passes in awnxov I would want words that have those letters to match,...

Is it possible to search all columns through MySQL table in PHP query, without typing out each column name?

php,mysql,search,like
I am asking this because I am looking for a PHP query for MySQL like the following: SELECT * FROM users WHERE ALL_COLUMNS LIKE '%" . $search . "%' Does a query like this exist? Or do I have to type the query like so: SELECT * FROM users WHERE...

MySQL with a LIKE returning wrong row

php,mysql,distinct,like
I have the following: $q = "w0"; $stmt = $db_found->prepare("SELECT DISTINCT callsign FROM NetLog WHERE callsign LIKE ?"); $stmt->execute(array("%q%")); $result = $stmt->fetchAll(); $print_r($result); It returns: Array ( [0] => Array ( [callsign] => KA0QIG [0] => KA0QIG ) ) So what went wrong? Why am I only getting one return...

Dynamically add like operators in where clause

sql,where,like
Can any one give me a solution for my problem? I have a string array of max length. I want compare all of my string array elements with a single SQL query. How can I do that? string[] new = searchtext; select Qid from questions where qdescriptions like string[0],string[1],string[2] The...

Using Like and Concat with Char Type

mysql,char,like,concat,varchar
I have a MySQL statement that is trying to find if the ID of a row (CHAR(36)) is inside of a string. My statement is : select * from `options` where concat('%',`OptionID`,'%') like '{\"4d519a3d-c99b-11e4-8eda-b8ca3a83b4c8\":\"62.50\"}'; But this fails and doesn't return anything, while this select * from `options` where `OptionID`='4d519a3d-c99b-11e4-8eda-b8ca3a83b4c8'; works...

SQL Concat or LIKE with wildcard?

sql,like,concat
The table includes two columns where one enumerates countries (name) and another capitals (capital). I need to find the country which name is included in its capital. For example country is Mexico and its capital is Mexico City. How is it possible to do using Concat or Like? Have tried...

SQL CASE LIKE with multiple choices

sql,sql-server,tsql,case,like
In my query I have following part of the code: CASE WHEN Field1 LIKE '%choice1%' OR Field1 LIKE '%Choice1%' .... THEN 'category 1' WHEN Field1 LIKE '%choicea%' OR Field1 LIKE '%Choiceb%' .... THEN 'category 2' END AS 'Cats' I have numerous of those choices (1line about 20), (2line about 15...

Multiple case insensitive like comparisons in mysql

mysql,sql,like,case-insensitive
I am trying to create a book store search field that matches keywords in a book's title, subtitle, and author columns. I can get a single case insensitive like statement to work, but it seems to not work when I try under multiple columns. Can anyone help me find what...

SQL statement search for all characters inside field

sql,search,like
I have an address field and address is stored similar to 1111 address info, county $stmt = $db->prepare('SELECT * FROM ' . Config::USER_TABLE . ' WHERE ' . Config::SEARCH_COLUMN . ' LIKE :query ORDER BY '.Config::SEARCH_COLUMN.' LIMIT ' . $start . ', ' . $items_per_page); $search_query = $query.'%'; $stmt->bindParam(':query', $search_query,...

Create custom like button in laravel4

php,laravel,like
Can someone tell me, step by step how can i create a functional like button? in my app? and how does it work so i just don't have to rely on your codes, so i can create my own like button by my own. And i hope someone will guide...