how to retrive the values from my sql table [closed] - php

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 want to retrieve (stratageeks,HCL,IMIMobile) value from the table where user_id=wordpress how it possible
This is my Table
id user_id company_name number_save
---------------------------------------------------------------
1 wordpress Stratageeks 1
2 Manju Stratageeks 1
3 Manju Wipro 2
4 wordpress HCL 2
5 wordpress IMIMobiles 3

SELECT company_name FROM table WHERE user_id='wordpress'
You should consider learning basic SQL if you plan on doing this in the future.
If you want distinct results, use:
SELECT distinct company_name FROM table WHERE user_id='wordpress'

Related

Mysql team/score [closed]

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 want to create an query to have the all matchs that a player win.
So, I have this table
ID_PLAYER1 ID_PLAYER2 SCORE_PLAYER1 SCORE_PLAYER2
1 4 5 3
2 1 3 4
3 4 2 0
I want to have this :
ID_PLAYER MATCH_WIN
1 2
2 0
3 1
4 0
Thank you !
I'm answering this because it's non-trivial and because I want to see if I can actually do it :p
SELECT `ID_PLAYER`, COUNT(*) AS `MATCH_WIN` FROM
(SELECT
IF(`SCORE_PLAYER1`>`SCORE_PLAYER2`, `ID_PLAYER1`, `ID_PLAYER2`) AS `ID_PLAYER`
FROM `your_table_name_here`
) AS `tmp`
GROUP BY `ID_PLAYER`

CakePHP Find Help (Condition) [closed]

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 database as follows
Name | Area 1 | Area 2
XYZ 200 300
ZUX 0 0
YYZ 100 200
What I want to do is, count the number of rows where SUM of (Area 1 and Area 2) is not equal to 0. In the example mentioned, It's 2. (SUM has to be calculated virtually)
I tried to use different ways with Find(); Still no luck.
Try this:
<?php
$this->Model->find('count', array(
'conditions' => array(
'(Area1 + Area2) != ' => 0
)
));
// returns 2
?>

Why when i select count with php i get just 1 instead of .. 55 for example || PHP Count, From last 100 [closed]

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
$nr333 = mysql_query("SELECT COUNT(*) AS cnt FROM (
SELECT * FROM games
WHERE human = '".mysql_real_escape_string($_GET[human])."'
ORDER BY id DESC LIMIT 100
) tmp WHERE changed = 'y'", $link) or die(mysql_error());
$frecventa333 = mysql_num_rows($nr333);
so bassicaly i dont get any error but .. instead of getting the real number i get just 1:|
http://s017.radikal.ru/i414/1310/a2/37958f7cdb48.png
That's because COUNT returns only one row, always. But in that row you'll find field with all rows counted, in one integer.
Try to fetch that row.
And next thing you should do is checking PDO extension. It's better than deprecated mysql_* functions and isn't so hard to learn.

Pull From Two MySQL Tables [closed]

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 two MySQL tables with the following...
Apps
ID | Name
1 App1
2 App2
and...
Minutes
ID | AppID | Amount
1 1 10
2 1 15
3 2 35
I want to pull the Apps and display them by time used. Should look like this...
App2 35 minutes
App1 25 minutes
How can I do this?
Thank you.
You can use a JOIN with a GROUP BY. To add the amounts together use the SUM aggregate funcion.
SELECT name, SUM(amount)
FROM `apps`
JOIN minutes ON `apps`.`id` = `minutes`.`appid`
GROUP BY `apps`.`id`
Use a JOIN (SQL):
SELECT
Apps.Name,
Minutes.AppID,
SUM(Minutes.Amount)
FROM Minutes
INNER JOIN Apps ON Apps.ID = Minutes.AppID
GROUP BY Apps.Name, Minutes.AppID

How can i fetch and compare time of related post from database? [closed]

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 am using mysql as database and saved time as time stamp of related posts in table, now i want to fetch the post made rrecently . How can i compare and fetch the post made recently?
you can fetch rows in descending order of your column (time_stamp).
ex:
SELECT * FROM Table_Name ORDER BY col_time_stamp DESC;
col_time_stamp : is the column
select top 1 * from posts order by timestamp desc
try this
SELECT * FROM Table_Name ORDER BY col_time_stamp DESC LIMIT 0;

Categories