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]';
Related
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 2 years ago.
Improve this question
i have a my sql table having 5 students and each gives 5 exams.
i need to get all the students that have got more than 70 marks in any subject with the name of the subject.
the table looks like this and i am new to mysql so i am not able to find the correct query.
please help !
In your case according to your database model I'd recommend making a query for each subject - 5 in total.
SELECT "enroll_no" FROM "tablename" WHERE "sub1_marks" > 70
and respectively do this for the other columns.
Replace "tablename" with the name of your table.
Each call will return a list of the enroll_no entries for where the number in the column you specified is greater than 70.
This is not very performant and you should change your model to have each exam on a separate row instead for a query like this.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a table named 'tweet' and its column 'text'. The column contains a sentence (many words) in each record. Then I wanna search the most word from the column. Is that possible to do that in MySQL query? If so, then I want to know also to add exception words like: 'a', 'I', etc...
I thought it's similar with this post
But it's using PHP.
I very appreciate for any help!
SQL is not the obvious tool for something like this. But, if you are going to use SQL, I would suggest that you parse the text into a TweetWords table, with one row per "tweet" and word in the tweet (along with position information).
If you are inserting the data through PHP, you can do the parsing there and then insert each word independently.
Then the count is easy, using a basic aggregation query.
Closed. This question needs to be more focused. It is not currently accepting answers.
Want to improve this question? Update the question so it focuses on one problem only by editing this post.
Closed 7 years ago.
Improve this question
I have a table named 'User' and it has an autoincremented field userID.
I want to retrieve that userID in my servlet. There is no such parameter/field referred to on that respective HTML. How can I use that userID in my servlet?
I would say your question is far to broad for a definite answer mate but here goes my best guess.
I assume you run this table and data in mysql since you tagged this as mysql.
you can retrieve the data you wish with the query as below:
SELECT userID FROM User;
Note: If you have more than 1 this will return all of them. If you want to limit this down to 1 you will need to match that to another unique parameter in your table. For example lets say you have a column in User table called "telephone"
the query would be:
SELECT userID FROM User WHERE telephone = '1234567890';
You can then display the result in your html, depending on what language you use to execute this query with.
Hope this helps
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 7 years ago.
Improve this question
I want to load data from database but how to get data in specific colmun
More Explanation:
lets say that we have a table called players, Then we have three columns "Username, Password and E-mail"
Now, if we want to select the email of the player who called "Nezo" how we can do it ?
This is a straightforward SELECT statement. I'd take some time to familiarize myself with the MySQL manual on SELECT, since it is among the most basic MySQL commands.
In this case, our select_expr (SELECT expression) is going to be the column from the table we're looking for, E-mail, and we're going to need to restrict the query to only look at the e-mail of the user named 'Nezo' using a WHERE clause:
SELECT `E-mail` FROM `players` WHERE `Username` = 'Nezo';
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 8 years ago.
Improve this question
I'm using MySQL 5.5.25 on Mac 10.7.5. I have a number of usernames in my database table of the form
prefix
prefix1
prefix2
prefix3
I would like to write a query that returns the username with the highest number after the prefix. For example, in the above list, the query would return "prefix3". Is there a way to do this with a single query?
Try This:
SELECT username FROM TABLE_NAME ORDER BY convert(REPLACE(username, 'prefix', ''), signed) DESC LIMIT 1
Make sure to put the correct PREFIX, USERNAME column name as well as the correct TABLE name.
You can sort them alphabetically, descending. The top result will be the highest number, provided they're formatted in a consistent way.