Home Tutorialhelp Comment computer consultant / programmer / linux sever adm

 
 

Comment

Dieter
computer consultant / programmer / linux sever adm,
September 23, 2010 at 8:41 PM

Your sql query: select Id, Name ,max(Marks) from stu group by id
insn't correct and may produce non valid results. You are realy "lucky" that your exemple produced (in this case) the right results. To garantie all time correct results you should replace your query by the following one:

SELECT Id, Name, Marks
FROM stu
WHERE (Marks, Id) IN (
SELECT max(Marks), Id
FROM stu
GROUP BY Id
)

with this query you also need to modify following line:

from: $marks=$sql_row["max(Marks)"];

to: $marks=$sql_row["Marks"];

Regards, Dieter from France
Nobody is perfect!
View All Comments
Advertisement
Related Tutorial and Articles
Java-Tutorials

SQL GROUP BY Example
SQL GROUP BY Example In this section we will discuss about the group by statement in SQL. In this tutorial we will use MySQL for using the SQL statements... either of the following syntax as per your requirements : SQL GROUP 

MySQL

PHP Mysql Group By
The Tutorial illustrate an example from PHP Mysql Group By. To understand and grasp... PHP Mysql Group By       PHP Mysql Group By is used to establish a relation between the PHP 

MySQL

SQL PHP Where
illustrate an example from 'SQL PHP Where'. To understand and illustrate... SQL PHP Where       SQL PHP Where is used to built the connection between the SQL and PHP 

Free SQL books

SQL Example, Codes and Tutorials
SQL Functions MySql Example... SQL Example, Codes and Tutorials   ... to the pass data value  back to the invoker.  SQL Bulk Insert Example 

Programming Tutorials

SQL Avg Group By
SQL Avg Group By       SQL Avg Group By helps you to find out average value of numeric field in a table. The SQL GROUP BY clause is used with the SQL aggregate functions 

SQL Question

mysql - SQL
mysql  hi i want to export my data from mysql to excel using php script. pls help me  Hi Friend, Please visit the following link: http://www.roseindia.net/sql/mysql-table/mysql-php-select.shtml Thanks 

Programming Tutorials

SQL Aggregate Functions Group By
with the use of 'SQL Aggregate Functions Group By'. In this example, we... SQL Aggregate Functions Group By       SQL Aggregate Functions Group By return the aggregate 

MySQL

SQL PHP
with Example The Tutorial illustrate an example from 'SQL PHP'. To understand and elaborate the example we have a  PHP server scripting code that includes host... SQL PHP       SQL PHP 

OpenSourceSoftware

Open Source SQL
shake. For example, the chapter covering the use of PHP with MySQL provides... forums is that of comparing the pros and cons of MySQL and MS SQL. While.... It is not true that MS SQL is better than MySQL or vice versa. Both products can 

SQL Question

saving the changes in Microsoft sql sever - SQL
saving the changes in Microsoft sql sever  How do we commit the changes in Microsoft sql server 

MySQL

sql php array
illustrate an example from 'SQL PHP Array'. To understand and grasp... sql php array       SQL PHP Array support simple dimension array. The SQL PHP Array is used 

SQL Tutorial

PHP SQL Table
on 'PHP SQL Table'. To grasp the example we create a sql_table.php begins with <... PHP SQL Table       PHP SQL Table is used to create table in PHP. To create a table in PHP 

SQL Question

mysql - SQL
mysql  How to insert the check box values in mysql database through php 

MySQL

PHP SQL close connection
'PHP SQL close Connection'. To understand and grasp the example we include... PHP SQL close connection       PHP SQL close connection is used to close a connection between the PHP 

SQL Tutorial

PHP SQL Update
; PHP SQL Update is used to execute the mysql _update () function that modify... an example from 'PHP SQL Update'. To understand and grasp the example we create... of any MySQL table in PHP. Syntax: The SQL syntax of UPDATE command is used 

PHP

PHP SQL Injection Example
PHP SQL Injection Example  This Example illustrates how to injection is used in the sql query.  The "SQL Injection" is subset...; are a different subset), and the idea is to convince the application to run SQL 

MySQL

PHP SQL Die
The Tutorial illustrate an example from 'PHP SQL Die'. To understand and grasp the example... INTO `stu` VALUES (6,'Tanuj',12); php_sql_group_by.php: The PHP code... PHP SQL Die       PHP 

SQL Question

MYSQL - SQL
MYSQL  how to select last row in table?(MYSQL databse)   How to select last row of the table in mySql Here is the query given below selects tha last row of the table in mySql database. SELECT * FROM stu_info 

PHP

Php Sql Script
Php Sql Script This example illustrates how to create the php sql script. In this example we create a table "emp_counter" with three column..._script.php  <?php   $mysql_db  

MySQL

PHP SQL Injection Example
PHP SQL Injection Example       PHP SQL  Injection Example is used to show you how... you to illustrate an example from 'PHP SQL Injection Example'. To understand 

Web Services

Web Programmer
; designing on Java/PHP/.Net. platform. Thorough knowledge of Linux and networking. At least 2+ yrs exp in application development environment, SQL Server... Web Programmer       

SQL Tutorial

SQL Aggregate Functions Group By
with the use of 'SQL Aggregate Functions Group By'. In this example, we... SQL Aggregate Functions Group By       SQL Aggregate Functions Group By return the aggregate 

SQL Tutorial

SQL Avg Group By
SQL Avg Group By       SQL Avg Group By helps you to find out average value of numeric field in a table. The SQL GROUP BY clause is used with the SQL aggregate functions 

SQL Tutorial

PHP SQL Select
; PHP SQL Select is used to execute mysql select query in the php application. The PHP SQL Select uses mysql_select_db () function that set the active MySQL... connection between the PHP and MySQL. Understand with Example This example illustrates 

MySQL

sql php code
sql php code       SQL PHP code executes the statement using the mysql_query ( ) function... with Example The Tutorial illustrate an example from 'SQL PHP'. To understand 

MySQL

PHP SQL Query Where Clause
PHP SQL Query Where Clause       This example illustrates how to create and execute the sql...; is executed using mysql_query() method to select only those employees who have programmer 

PHP

Php Sql Variable
Php Sql Variable This example illustrates how to create the variable in php for sql operation. In this example we create a variable $con for mysql... insertion   Source Code of sql_variable.php <?php 

SQL Tutorial

SQL
SQL - SQL Introduction     SQL - An Introduction to the Structured Query Language SQL stands for Structured Query Language (SQL), a standard language used for creating, updating, querying 

SQL Question

sql - SQL
the example and also what is the data type for image in database.. pleas send the answer to me with example of table and servet.   Hi friend... connectionURL = "jdbc:mysql://192.168.10.211:3306/amar"; java.sql.Connection 

MySQL

PHP SQL Connection
between PHP and SQL. To understand the example we create a table 'Stu... PHP SQL Connection       PHP SQL Connection is used to access and return the records from PHP 

SQL Tutorial

PHP SQL Fetch
PHP SQL Fetch       PHP SQL Fetch is used to fetch the records from Mysql database to PHP... The Tutorial illustrate an example from PHP SQL Fetch. To understand and grasp 

PHP

Php Sql Null
Php Sql Null This example illustrates to describe about null value of execution of sql query in php.  In this example we select data from database...;   $result = mysql_query( $sql, $conn  

SQL Tutorial

PHP SQL Insert
an example from PHP SQL Insert . To understand the example, firstly we need... PHP SQL Insert       PHP SQL Insert is used to insert the record from HTML page to Mysql  

General

MySQL default port number in Linux
MySQL default port number in Linux - How to find the default port number of MySQL in Linux? If you are using MySQL database server installed on the Linux... of MySQL in Linux?". After find the port number you can connect 

SQL Tutorial

PHP SQL Insertion
PHP SQL Insertion       PHP SQL Insertion is used to execute MySQL queries in PHP script.... Understand with Example The Tutorial illustrate an example from 'PHP SQL Insertion 

MySQL

PHP SQL Script
; Understand with Example The Tutorial illustrate an example from 'PHP SQL Script... PHP SQL Script       PHP SQL Script is useful to perform the operation of SQL queries in PHP 

SQL Tutorial

SQL Functions
.    PHP SQL Timestamp In this example... in this Tutorial illustrate an example from 'Mysql Update'.To grasp this example we... The Tutorial in this section illustrate an example from 'Mysql Now Current Date Time 

MySQL

PHP SQL Injection Attack
with Example The Tutorial illustrate an example from PHP SQL Injection... PHP SQL Injection Attack       PHP SQL Injection Attack refers to the act of  someone 

SQL Question

SQL
SQL  In my computer i have microsoft sql 2008.how can i set that in the cmd.i want to use that in cmd.what is the default username and password 

PHP

Php Sql Table
Php Sql Table  This example illustrates how to create table in php. In this example we create a table "emp_table" with three fields, "...   Source Code of sql_table.php  <?php   

SQL Question

sql
sql  returning value from a store procedure in sql with example   Please visit the following links: http://www.roseindia.net/mysql/mysql5/stored-procedures-and-functions.shtml http://www.roseindia.net/sql/create 

MySQL

Php Sql Paging OR Pagination
Php Sql Paging OR Pagination   ... in php. Some times the programmer needs to display a large amount of data.... In this example, we have to display maximum 10 rows per page. According 

MySQL

PHP SQL Variable
illustrates how to create the variable in php for sql operation. In this example... PHP SQL Variable       PHP SQL Variable are denoted with a leading dollar sign ($). The PHP  

SQL Question

Inserting Data into mysql - SQL
noticed there is no category for php. However am hoping my question will fit into the SQL category though under php. I need help with reading from a csv file (using php)and inserting the details in a mysql database. Lets take for instance 

MySQL

PHP SQL Quotes and Quoting
PHP SQL Quotes and Quoting     ... quotes in the php application with sql query. In php page, if user enters data... Code of sql_quotes.php  <?php   $con  

PHP

Php Sql Quotes and Quoting
Php Sql Quotes and Quoting This example illustrates different ways to define single and double quotes in the php application with sql query. By default, PHP...; <?php   $con = mysql_connect("localhost"," 

SQL Tutorial

PHP SQL Array
PHP SQL Array       PHP SQL Array is the set of collection of one or more similar variable under... illustrates how to create array in the operation of sql for php application 

General

The Beginners Linux Guide
system.    PHP MySQL on Centos 5.x Learn how to install MySQL support in PHP on Centos 5.x servers.   ...The Beginner's Guide to Linux Dedicated website to Linux containing Online 

SQL Tutorial

PHP SQL Rows
The Tutorial illustrate an example from 'PHP SQL Rows'. To understand the example... MySQL query in PHP, we make use of mysql_function ( )  that run the sql... PHP SQL Rows       

SQL Tutorial

PHP SQL Insert Statement
The Tutorial illustrate an example from 'PHP SQL Insert Statement'. To understand and illustrate an example 'PHP SQL Insert Statement', we create a table 'stu... PHP SQL Insert Statement      

MySQL

PHP SQL Select Where
from 'PHP SQL Select Where'. To understand and grasp the example we create... PHP SQL Select Where       PHP SQL Select Where is used to provide the records from the table 

Quartz Tutorials

SQL NOW() Function
to your computer's system date and time.  The SQL syntax for the Now... The Tutorial helps you to illustrate a example from SQL NOW( ) Function...SQL NOW() Function       

SQL Question

SQL
SQL Trigger query  Why we use the Trigger and what it's uses?  ... customized database management system. For example, you can use triggers to: 1..., user events, and SQL statements to subscribing applications 10)Restrict DML 

MySQL

PHP SQL LIKE Operator
PHP SQL LIKE Operator       This example illustrates how to use the like operator in sql query... <?php   $con = mysql_connect(" 

MySQL

PHP SQL Example
PHP SQL Example      ... an example from PHP SQL Example. To understand and grasp the example we create...); php_sql_example.shtml: The PHP code is executed on the server side and sent 

MySQL

PHP SQL Random
; Understand with Example The Tutorial illustrate an example from PHP SQL Random... PHP SQL Random       The PHP SQL Random is used to fetch data randomly from database in PHP. The Rand 

SQL Question

SQL
SQL  what data type we use for the uploading the video and image files in MySQL server 2008 

SQL Question

SQL
a highly customized database management system. For example, you can use triggers... events, user events, and SQL statements to subscribing applications 10)Restrict DML 

SQL Question

SQL
a highly customized database management system. For example, you can use triggers..., user events, and SQL statements to subscribing applications 10)Restrict DML 

SQL Question

SQL
customized database management system. For example, you can use triggers to: 1... events, and SQL statements to subscribing applications 10)Restrict DML 

SQL Question

Sql question
Sql question  How to display duplicate values in Sql?   Hi Friend, Please visit the following link: http://www.roseindia.net/sql/mysql-example/mysql-finding-duplicate-records.shtml Thanks 

SQL Question

insertion in SQL - SQL
in the database because of single code in the name. dbase is MS-SQL emp.name data type... as I know string parameter in SQL is denoted as 'john' . I think thats why... static void main(String[] args) { System.out.println("Insert records example 

PHP

Php Sql Select
Php Sql Select  This example illustrates how to execute mysql select query in the php application. In the previous example we have already execute many... show mysql_select_db method, how it work and how it is used in php application 

SQL Tutorial

PHP SQL Where
. Understand with Example The Tutorial illustrate an example from 'PHP SQL Where... PHP SQL Where       PHP SQL Where is used to modify or change the structure of  table 

MySQL

PHP SQL Injection
with Example The Tutorial illustrate an example from PHP SQL Injection... PHP SQL Injection       PHP SQL Injection is an interface that facilitate access  

MySQL

PHP SQL Result
PHP SQL Result       This example illustrates how to display result on the browser and how to use...;?php   $con = mysql_connect("localhost"," 

MySQL

PHP SQL Limit
PHP SQL Limit       This example illustrates how to execute LIMIT operator of mysql in PHP.  In this example, we have created a limit.php page, in which we execute a query 

SQL Question

mysql table construction - SQL
mysql table construction  In MySql there is no pivot function. using a function or Stored Procedure, I want to loop through a column of data... data. Example: table1 a,b,c chi, 12,xx nyc,15,xx atl,16,xx sf,17,xx 

PHP Questions

php
php  retrieve data from mysql in php   Please visit the following links: http://www.roseindia.net/sql/mysql-table/mysql-php-select.shtml http://www.roseindia.net/sql/mysql-example/select-where.shtml 

PHP

PHP SQL Limit
PHP SQL Limit This example illustrates how to execute LIMIT operator of mysql in PHP.  In this example we create a limit.php page, in which we execute... of limit.php  <?php   $con = mysql 

SQL Question

SQL
with example 

PHP Tutorial

PHP Tutorials from RoseIndia
order or descending order.   PHP MySQL Update: In SQL, Update... to be updated.   PHP MySQL Delete: In SQL, sometimes we need... in PHP. Top Tutorials of PHP PHP Tutorial Starting PHP PHP MySQL Zend 

SQL Question

mysql select statement - SQL
mysql select statement  i want to select id,name,age values from... a[]) { Connection con = null; String url = "jdbc:mysql... for more information with example http://www.roseindia.net/jdbc/ Thanks 

MySQL

PHP SQL Output
PHP SQL Output      .... In the example below, we have created sql_output.php where a sql query is executed...; <?php   $con = mysql_connect("localhost"," 

SQL Question

MySQl - SQL
MySQl   How to Remove password for root in MY SQl.....? Please Provide the steps Immediately 

SQL Question

sql - SQL
order by SQL Query  What is order by in SQL and when this query is used in SQL?Thanks!  Hi,In case of mysql you can user following query.Select salary from salary_table order by salary desc limit 3,1Thanks 

SQL Question

group by sorting
group by sorting  group by sorting of data in SQL 

SQL Question

MySQL - SQL
MySQL  how to set a time to repeat a trigger in Mysql?  Hi Friend, Please visit the following links: http://www.roseindia.net/mysql/mysql5/triggers.shtml http://www.roseindia.net/sql/trigger/mysql-time 

MySQL

PHP SQL Max
PHP SQL Max       This example illustrates how to use max() function in sql. In this example... by clause has been used in the example to group the result on the basis of same 

SQL Question

mysql - SQL
mysql  hi sir i want to display first two person highest salary in mysql  Hi I am sending a link where u can find max function to find the maximum marks of student. http://www.roseindia.net/sql/sql-aggregate 

SQL Tutorial

PHP SQL Search
PHP SQL Search       PHP SQL Search is used to return the records details from the table based on the search condition. The PHP SQL Search allows the user to put his search 

SQL Question

php sql problem - SQL
php sql problem  I ahve a php code that doesn't allow me to get the vat value from db. i tried to add $vat = 21; below $shippingCost = 10; but doesn't work. why?? The vat is not returning any values.   Hi friend 

SQL Question

sql - SQL
want query? 4.what is the diffrence between sql and plsql?  Hi Friend... employee according to emp_id: SELECT *, count(*) as n FROM employee group by emp_id HAVING n>1; Difference between SQL and PL/SQL: SQL is a structured query 

MySQL

PHP Mysql Database Connection
between the PHP on the server-side and Mysql on the backend. Understand with Example The Tutorial illustrate an example from PHP Mysql Database Connection...` VALUES (5,105); php_sql_group_by.php: The PHP server side include 

MySQL

PHP SQL Query
PHP SQL Query       This example illustrates how to create and execute the sql query in php... how to use sql queries in php, we have created sql_query.php page. First 

MySQL

PHP SQL IF Statement
PHP SQL IF Statement       This example illustrates how to use the 'if' statement in php when accessing the data from table in mysql database. In this example we create a connection 

PHP

PHP SQL IF Statement
PHP SQL IF Statement  This example illustrates how to use the 'if' statement when accessing the data from mysql database table in php.  In this example we create a connection from database table using mysql_connect(" 

MySQL

PHP SQL Number of Rows
PHP SQL Number of Rows      ...; <?php   $con = mysql_connect('localhost','root...;* from users";   $res = mysql_query($sql 

SQL Question

mysql - SQL
mysql  hi i am using mysql. i want to create simple table...=INNODB; For more information MySql visit to : http://www.roseindia.net/mysql/ Thanks 

PHP

PHP SQL LIKE Operator
PHP SQL LIKE Operator This example illustrates how to use the like operator in sql query. The LIKE operator is used in a WHERE clause to search... <?php   $con = mysql_connect(" 

PHP

PHP SQL Inner Join
PHP SQL Inner Join  This Example illustrates how to use the inner join clause in the sql query. The inner join return rows when there is at least one match in both tables. This is the good example to understand inner join clause 

SQL Question

sql - SQL
sql functions with examples  I need sql functions with examples... = "jdbc:mysql://localhost:3306/"; String db = "register"...("SQL statement is not executed!"); } } catch (Exception e 

SQL Question

mysql - SQL
 

SQL Question

sql - SQL
on MYSql visit to : http://www.roseindia.net/jdbc/jdbc-mysql/ Vineet 

Hibernate-Tutorials

Hibernate GROUP BY Clause
BY clause. GROUP BY clause in HQL is used as same as it is used in SQL... a simple example which will demonstrate you how a HQL group by clause can.... In this example we will calculate the price of each group of purchaser. Complete Code 

SQL Question

servlet - SQL
servlet  I have a mysql database which has a table named 'computer' and there are 3 columns are id,Cname,quantity. I would like to retrieve column... = stm.executeUpdate("update computer set Cname='RAM' where id='01'"); but I would like 

MySQL

PHP SQL Query Insert
PHP SQL Query Insert       This example illustrates how to execute insert query in php application. To understand how to use sql insert queries in php, we have created 

Hibernate Tutorial Example

HQL Group By Clause Example
HQL Group By Clause Example   ... by grouping on returned component. HQL supports Group By Clause. In our example we...;Clause Example   String SQL_QUERY = "select sum 

PHP

PHP SQL Right Join
PHP SQL Right Join  This Example illustrates how to use right join clause in the sql query. The right join return all rows from the right table, even... <?php   $con = mysql_connect("localhost" 

PHP

PHP SQL Left Join
PHP SQL Left Join  This Example illustrates how to use left join clause in the sql query. The left join return all rows from the left table, even if there are no matches in the right table. In this example left join is used 

Advertisements Advertisements
 

 

 

DMCA.com