Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 8 years ago.
Improve this question
I have a mysql table with a numbers column, this contains a list of UK mobile phone numbers (beginning in 07) and some UK landline numbers (beginning in 01).
How could I query for just the land line numbers?
I know I could use some kind of regex in my application, but if possible I would rather do it using a query.
Any help would be appreciated!
Select * from MyTable where phoneNumber like '01%';
Try
Select * from `someTable` where `phoneNumber` like '01%';
Use the Like operator in your query. For example "select number from tbl where number Like '01%'"
Try to read something about the WHERE condition and LIKE comparison.
For example here: The SQL LIKE Operator
Related
Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
Hi I am trying to make a very basic sql query from a mysql table.
SELECT VAV,floor from Mapping limit 10;
output is
But when I try with
SELECT VAV,floor from Mapping where floor='B2WL1';
It outputs an empty set. I am very surprised with this. I have also tried with spaces like
SELECT VAV,floor from Mapping where floor=' B2WL1';
SELECT VAV,floor from Mapping where floor='B2WL1 ';
it is returning empty set. Can someone help me with this. Really stuck at this.
try:
where floor like '%B2WL1%';
Probably has whitespaces or any other hidden characters
you may try with wild characters like
SELECT VAV,floor, LENGTH(floor) as number_of_characters
from Mapping
where floor like '%B2WL1%';
Closed. This question needs details or clarity. It is not currently accepting answers.
Want to improve this question? Add details and clarify the problem by editing this post.
Closed 6 days ago.
Improve this question
I have a table with a column called 'description' which is the description of an ad, and i want to know how many ads include the seller phone number in the description.
for example:
'car for sale. Toyota Corolla. Call 0759485102'
(all phone numbers have 10 digits)
how can i query that? im using mysql in datagrip
Most databases support regular expressions -- at least sufficiently to start to answer this question. You can look for a 10-digit string. There is no way to know if this is really a telephone number (unless you have that somewhere else).
For instance, in MySQL, you can do:
select count(*) as num_with_10digits
from t;
where description regexp '[0-9]{10}';
The where clause differs by database, but the idea would be the same in most databases.
You can use like predicate :
select count(*)
from table t
where description like '[0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]';
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question appears to be off-topic because it lacks sufficient information to diagnose the problem. Describe your problem in more detail or include a minimal example in the question itself.
Closed 8 years ago.
Improve this question
Any thoughts on why WHERE clause would not work? I have made sure I have double checked the coding and spelling etc. It will not work with a simple WHERE clause, and I have tried using different operators, operators that I know are in the table. I have tried using trailing spaces, I have copied and pasted the output from SELECT DISTINCT column_name FROM table. In short I have really made sure that it is not just some dumb error on my part before posting this question.
Here are the specs of the column that is giving me trouble. UTF8_General_Ci and it VARCHAR(100).
I have never had any problems with a WHERE clause, not like this at least. Any thought? Thanks in advance
Here is the code;
SELECT site_specialty
FROM site WHERE site_specialty='INTERNAL MEDICINE'
there is no error message, it just comes up blank 0 rows returned
try this
SELECT site_specialty FROM site WHERE site_specialty LIKE '%INTERNAL MEDICINE%'
Before giving up entirely, I would try:
SELECT site_specialty
FROM site
WHERE upper(site_specialty) like '%INTERNAL%MEDICINE%';
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
How can I simulate that my MySQL field is an array, and later with some query to search element in that array ?
In only MySql:
To get the field.
select FIELDNAME from TABLE
To search from that result set:
select FIELDNAME from TABLE where FIELDNAME like '%myvalue%'
The %'s are wild cards. This would return any value with myvalue in it.
Such as:
(amyvalue, bmyvalueb, I<3myvaluecompletely)
If you want this done in some language you need to provide a more verbose and detailed question.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
Questions asking for code must demonstrate a minimal understanding of the problem being solved. Include attempted solutions, why they didn't work, and the expected results. See also: Stack Overflow question checklist
Closed 9 years ago.
Improve this question
I have a column with values like 24,25,26,27 and
I want to match 24 (or some other number).
I like to do it based on regex don't know how to do?
I want the matching should be clear like 24,25,26 should match with 24 not 243
You can take a look at
FIND_IN_SET
SELECT FIND_IN_SET('24','24,25,26 ');
Note Please don't store vales as comma separated instead normalize
your structure