Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 7 years ago.
Improve this question
I want to store user defined variables in sql select statement and use that variable in sub query like the following:
select user_id, #user_gender:=user_gender
where user_id in (select user_id from post where post_gender=#user_gender);
So what I want to do here is I want to store the user_gender value into a variable and use it in a subquery. I know what I am tryinig to do here can be achieved by joins, but what I am posting this example, because I want to know how to actually store value from a row into a user defined variable.
Also, I am having hard time finding good resources that explains how to use user defined variables. Any recommendations?
Use following query :
SELECT user_id FROM post , ( SELECT #user_gender:='MALE' ) AS var WHERE post_gender=#user_gender;
check link for reference
Related
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
This question does not appear to be about a specific programming problem, a software algorithm, or software tools primarily used by programmers. If you believe the question would be on-topic on another Stack Exchange site, you can leave a comment to explain where the question may be able to be answered.
Closed 2 years ago.
Improve this question
I'm trying to run a query that returns the maximum number in the ballNumber field when the value in the inningsNo field is 1. I just can't get it to work. Can anyone tell me what I should enter into the Criteria box?
Thanks
Rob,
To do this, you will need to do the following:
Click on the "Totals" button on the Query ribbon (a new row will appear in the Query grid labelled "Total");
Change the "Group By" Total value to "Where" in the InningsNo column (the tick in the "Show" will also disappear);
Change the "Group By" Total value to "Max" in the ballNumber column.
Regards
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 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 the following two MySQL tables for emails...
mail_emails
Columns: id, folder, user
mail_folders
Columns: id, name, user
I want to use only a single MySQL query to fetch the folder names and the number of emails per folder. Presuming the user id is 1, what would be the most efficient approach to this goal?
I am not exactly sure of your database structure. But this should give you an idea.
SELECT *, count(e.folder) totalMail FROM mail_folders f INNER JOIN mail_emails e on e.folder = f.name WHERE f.user = '1' GROUP BY e.folder
I am assuming that the name field in the mail_folders table is the same value that will be stored in folder field of mail_emails table.
Closed. This question does not meet Stack Overflow guidelines. It is not currently accepting answers.
We don’t allow questions seeking recommendations for books, tools, software libraries, and more. You can edit the question so it can be answered with facts and citations.
Closed 8 years ago.
Improve this question
i have created a testimonial table in database .i have inserted three testimonials. I want to show one testimonial per day.is there any good tutorial for doing this ?
CREATE TABLE customer_testimonials
( testimonial_id integer unsigned NOT NULL auto_increment PRIMARY KEY,
testimonial_text varchar(50) NOT NULL
);
You can achive this by a scheduled task. Write a (php, bash, ??) script to get max id of testimonials, generate a random number smaller than max id and writes this to the file, then run this script once for 24 hours. In your web page, always read this file to take testimonial id and query your table to get this testimonial. With this approach, you will be able to show one testimonial per day.
If you are using linux you can schedule this task by crontab.
http://adminschoice.com/crontab-quick-reference
http://php.net/manual/en/book.mysql.php
http://php.net/manual/en/function.rand.php
http://php.net/manual/en/function.fwrite.php
.
.
.