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
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 4 years ago.
Improve this question
I am currently logged in as the first student. I want to retrieve a list of the students I did not send a request to yet. I also want to retrieve a list of students I sent a request to.
Both sender_id and Rec_id are foreign keys referencing to Students.id.
DB schema
Hi Souleiman and welcome to stackoverflow! Your question is not quite clear, you say that sender_id and Rec_id in requestts are both referencing to students, but you can't see to which field exactly. Your requestts table contains different entries in these fields.
Next time you should post the output of SHOW CREATE TABLE students and SHOW CREATE TABLE requestts and a little INSERT statement for the data. Furthermore it would be nice if you would explain the relations and show what you have already tried (see Barmars comment).
I suppose that the relevant foreign key in requestts is Rec_id, so you could try this query:
SELECT s.email FROM students s WHERE s.id NOT IN
(SELECT Rec_id FROM requestts WHERE Rec_id = s.id);
Hope this helps. Have fun learning SQL!
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 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 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 8 years ago.
Improve this question
I have a two table first is simple primary key based table and second table is keyvaluepair for maintaining records.
Now I want to get records from Table in a single object. If they come as comma separate it's good.
Suppose I have table
ID valueID.
When I will run select query I not want a list of rows. I want a single column (in a row) that I can get the information about all valueIds.
Could someone explain me how can I get them in one instead of list?
You probably want to use GROUP_CONCAT.
SELECT GROUP_CONCAT(valueID) FROM table
http://dev.mysql.com/doc/refman/5.0/en/group-by-functions.html#function_group-concat
If you need both the ID and the valueID, you're better off sticking with an array.