SELECT *
FROM TABLE
WHERE column_name LIKE N'%Ө%'
When I use this query, it returns all rows of the table.
It works like :
SELECT *
FROM TABLE
WHERE column_name LIKE '%%'
I also tried :
SELECT *
FROM TABLE
WHERE column_name LIKE N'%ӨTӨEӨSӨTӨ%'
and it works like :
SELECT *
FROM TABLE
WHERE column_name LIKE '%TEST%'
use collation Cyrillic_General_100_CI_AS, like this:
SELECT *
FROM TABLE
WHERE column_name LIKE N'%Ө%' COLLATE Cyrillic_General_100_CI_AS
OR column_name LIKE N'%ӨTӨEӨSӨTӨ%' COLLATE Cyrillic_General_100_CI_AS
Related
I would need to find all %phone% instances from all tables in a specific DB.
This is my script i'm trying with yet still getting all the DBs (I need only from DB1):
use DB1;
SELECT *
FROM
information_schema.columns
WHERE
column_name LIKE '%phone%';
I also tried writing like this:
SELECT *
FROM
DB1.information_schema.columns
WHERE
column_name LIKE '%phone%';
but I got a SQL Error [1064] [42000] for that syntax.
What would be the correct way to query this?
There's only one INFORMATION_SCHEMA database for all the databases on the server. The table database is in the table_schema column of the columns table.
SELECT *
FROM information_schema.columns
WHERE table_schema = 'DB1' AND column_name LIKE '%phone%';
I used the following for '%email%'
and it worked.
So i guess it would for for you too:
SELECT
DISTINCT TABLE_NAME
FROM
INFORMATION_SCHEMA.COLUMNS
WHERE
COLUMN_NAME LIKE ('%phone%') AND TABLE_SCHEMA='DB1';
use the parameter TABLE_SCHEMA, to select your scheam/database
SELECT *
FROM
information_schema.columns
WHERE
column_name LIKE '%phone%'
AND TABLe_SCHEMA = 'DB1';
how to use like function which contains space as one of the character in msql.
In my database, i am having column name as "contractor_id".
This is my code for selecting column name from table.
SELECT COLUMN_NAME as a FROM INFORMATION_SCHEMA.COLUMNS WHERE table_name = '$table' AND column_name LIKE '%".actor id."%'.
Just leave out the quotation marks like
SELECT COLUMN_NAME as a
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_name = '$table'
AND column_name LIKE '%actor id%'
Or, in case you are generally looking for a column name with a blank in it use
... column_name like '% %'
I have a table with 300+ column. Looking for a specific column is like nightmare. Is there any query where If I would like to search for columns stats with 'grand' can be listed...
You can use show columns from table with where. Try the following query,
SHOW COLUMNS FROM tablename WHERE field like 'grand%';
Just put in your tablename after FROM and it would work.
select * from myTable where mycolumn like 'grand%'
Try this.
SELECT
table_name,
column_name,
data_type,
ordinal_position
FROM INFORMATION_SCHEMA.COLUMNS
WHERE table_schema = 'DatabaseName' --- the database you want to search
AND table_name = 'yourTableName'
AND column_name LIKE '%Grand' ;
This one worked for me. Its shows all columns and table in entire database
SELECT TABLE_NAME, COLUMN_NAME
FROM INFORMATION_SCHEMA.COLUMNS
WHERE column_name OR table_name LIKE '%sale%';
i try to find %column_name% from another table_name i see the result
but he seems to ignore the %%
Why it does not work for me?
SELECT column_name FROM table_name WHERE NOT LIKE '%(SELECT column_name FROM table_name)%'
thanks,
Apologies if I do not act according to the rules, this is my first question.
Try this:
SELECT column_name FROM table_name WHERE NOT LIKE (SELECT CONCAT('%', column_name, '%') FROM table_name)
You can't just include a query in a string, so put the wildcards next to the column name in a query and return that to the NOT LIKE.
SELECT column_name
FROM table_name T
WHERE NOT EXISTS ( SELECT column_name from other_table O
WHERE O.column_name LIKE CONCAT('%',T.column_name,'%')
)
I was thinking I could do that like SELECT * FROM table_name WHERE column_name=UNDEFINED, but I couldn't. I think there is a simple way to do that?
It all depends on what you think is UNDEFINED.
The most basic case is that your column_name is nullable, so your query would look like:
SELECT * FROM table_name WHERE column_name IS NULL
In mysql you compare to NULL values with something like:
SELECT * from table_name where column_name IS NULL