Re: [PHP] select distinct mysql

2002-08-16 Thread Analysis & Solutions

On Thu, Aug 15, 2002 at 01:12:59PM +0300, kale wrote:
> 
> SELECT *, DISTINCT name FROM history ORDER date DESC, time DESC LIMIT 10
>
> but this not work. how can I do this?  I use a mysql server.

That's because your query string syntax is all messed up.

Put a mysql_error() call in your script after the mysql_query() call.  It 
will tell you what the error is.  
   http://www.php.net/manual/en/function.mysql-error.php.

(Or, of course, you can execute the query directly from your MySQL client
command line.)

If you're unclear about what the error message is saying, read the MySQL 
manual on how to write SELECT statements.
   http://www.mysql.com/doc/en/SELECT.html

--Dan
 
-- 
   PHP classes that make web design easier
SQL Solution  |   Layout Solution   |  Form Solution
sqlsolution.info  | layoutsolution.info |  formsolution.info
 T H E   A N A L Y S I S   A N D   S O L U T I O N S   C O M P A N Y
 4015 7 Av #4AJ, Brooklyn NY v: 718-854-0335 f: 718-854-0409

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP] select distinct mysql

2002-08-15 Thread kale

hy,
I have a tabel (history) with fields:
id (uniq), date, time, name, etc.
I want to select after next rules:
- date and time been sort descendent
- only 10 recording
- value of the field name to be unique
syntax must be something this:

SELECT *, DISTINCT name FROM history 
ORDER date DESC, time DESC LIMIT 10

but this not work. how can I do this?

this is structure of tabel:
id  namedate time  ...etc
--
1. kale 2002-03-15   14:12_14 
2. smith   2002-04-17   15:14:13 
3. kale 2002-05-15   16:14:13 .

I want that result contains only recordings 2 and 3
not 1 because it's same name and it is older then 3.

I use a mysql server.
thanks for help
kale