MYSQL!!

  Mary_S 12:19 01 Feb 06
Locked

Hi,

Im creating a website using PHP and MYSQL. I need mysql to select the lowest number from a column hence im using the following query;

mysql> SELECT MIN (number) AS number FROM shop;

BUT, i get the following eror messsage;

ERROR 1305 (42000): FUNCTION ecommerce MIN does not exist

Can any1 help??

Thank You

  harristweed 13:31 01 Feb 06

I don't know how to word that the query.

But as a work around, this (php) will do the job.

<?php
$db_database="database";//put the correct info in here
$db_host="localhost";//and here
$db_password ="password";//and here
$db_user ="user";//and here
$link_id = mysql_connect("$db_host","$db_user","$db_password");
if (mysql_select_db("$db_database", $link_id));
$select = "SELECT column_name FROM table_name order by price asc ";//put the column name and table name in here
$results = mysql_query("$select", $link_id);
$query_data = mysql_fetch_row($results);
$number = $query_data[0];
echo "minimum number = $number";
?>


What it does is get all the numbers, sorts them, lowest at the top, then returns the top number from the list.

Hope this helps

  harristweed 13:32 01 Feb 06

$select = "SELECT column_name FROM table_name order by price asc ";//put the column name and table name in here

should read

$select = "SELECT column_name FROM table_name order by column_name asc ";//put the column name and table name in here

  harristweed 08:03 02 Feb 06

try this (php)....
$db_database="database";//put the correct info in here
$db_host="localhost";//and here
$db_password ="password";//and here
$db_user ="user";//and here
$link_id = mysql_connect("$db_host","$db_user","$db_password");
if (mysql_select_db("$db_database", $link_id));
$select=" SELECT MIN (number) AS number FROM shop";
$results = mysql_query("$select", $link_id);
$query_data = mysql_fetch_row($results);
$number =$query_data[0];
echo "Lowest = $number";

This thread is now locked and can not be replied to.

Nintendo Switch review: Hands-on with the intuitive modular console and its disappointing games…

1995-2015: How technology has changed the world in 20 years

This abstract video touches on division in our technologic world

Best alternatives to iTunes for Mac | Best music players for macOS: Free your music from the…