Re: [PHP-DB] Re: Very complex query

2003-12-11 Thread Justin Patrin
Martin Marques wrote:

El Jue 11 Dic 2003 05:30, Mike U. Petrov escribió:

I tried to use GROUP BY and it worked almost right but i need to return
user_id and mysql generated an error that notes.user_id isn't used in GROUP
BY...


Add it to the GROUP BY.

But he wants only one entry for user_id, not all of them. Adding it will 
negate the reason he's using it.

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


Re: [PHP-DB] Re: Very complex query

2003-12-11 Thread Martin Marques
El Jue 11 Dic 2003 05:30, Mike U. Petrov escribió:
> I tried to use GROUP BY and it worked almost right but i need to return
> user_id and mysql generated an error that notes.user_id isn't used in GROUP
> BY...

Add it to the GROUP BY.

-- 
 16:33:02 up 15 days, 22:49,  4 users,  load average: 0.03, 0.32, 0.46
-
Martín Marqués| select 'mmarques' || '@' || 'unl.edu.ar'
Centro de Telematica  |  DBA, Programador, Administrador
 Universidad Nacional
  del Litoral
-

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



Re: [PHP-DB] Re: Very complex query

2003-12-11 Thread Martin Marques
El Jue 11 Dic 2003 05:17, Mike U. Petrov escribió:
> No, DISTINCT isn't match my purpose cause of it rerurns unique rows but I
> need ONE user_id per one object_id.

GROUP BY is your answer.

-- 
 15:51:02 up 15 days, 22:07,  3 users,  load average: 0.90, 0.75, 0.61
-
Martín Marqués| select 'mmarques' || '@' || 'unl.edu.ar'
Centro de Telematica  |  DBA, Programador, Administrador
 Universidad Nacional
  del Litoral
-

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



Re: [PHP-DB] Re: Very complex query

2003-12-11 Thread Martin Marques
El Jue 11 Dic 2003 05:00, Muhammed Mamedov escribió:
> You can also DISTINCT command instead.
> UNIQUE command isnot supported by mySQL (at least at MySQL 3.23.41- I am
> using)

UNIQUE is for table creation or index creation. It is relevent for insertion, 
not selects.
DISTINCT and DISTINCT ON() are used in SELECT statements.

-- 
 15:49:01 up 15 days, 22:05,  3 users,  load average: 1.12, 0.79, 0.61
-
Martín Marqués| select 'mmarques' || '@' || 'unl.edu.ar'
Centro de Telematica  |  DBA, Programador, Administrador
 Universidad Nacional
  del Litoral
-

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



RE: [PHP-DB] Re: Very complex query

2003-12-11 Thread Mike U. Petrov
I tried to use GROUP BY and it worked almost right but i need to return
user_id and mysql generated an error that notes.user_id isn't used in GROUP
BY...

Mike U. Petrov


-Original Message-
From: Justin Patrin [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 11, 2003 11:25 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Re: Very complex query


Mike U. Petrov wrote:

> First, sorry my starnge way to post new thread.
> Second:
> I want to specify some features:
> in my table notes I've a lot of user_id's for each object_id and I don't
> want to find unique user_id, I only want to find one user_id for each
> object_id, so unique(user_id) doesn't match. Do u have any other ideas?
>
> Mike U. Petrov
>
>
> -Original Message-
> From: Justin Patrin [mailto:[EMAIL PROTECTED]
> Sent: Thursday, December 11, 2003 10:53 AM
> To: [EMAIL PROTECTED]
> Subject: [PHP-DB] Re: Very complex query
>
> Use unique(user_id). And please don't reply to a previous post when
> posting a new threadit screws up threading.
>
> --
> paperCrane 
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php

Oops, sorry about that. What you could do is:

GROUP BY object_id

or

GROUP BY object_id, other_field, other_field2, etc

Just don't group by user_id.

--
paperCrane 

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

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



Re: [PHP-DB] Re: Very complex query

2003-12-11 Thread Justin Patrin
Mike U. Petrov wrote:

First, sorry my starnge way to post new thread.
Second:
I want to specify some features:
in my table notes I've a lot of user_id's for each object_id and I don't
want to find unique user_id, I only want to find one user_id for each
object_id, so unique(user_id) doesn't match. Do u have any other ideas?
Mike U. Petrov

-Original Message-
From: Justin Patrin [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 11, 2003 10:53 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Re: Very complex query
Use unique(user_id). And please don't reply to a previous post when
posting a new threadit screws up threading.
--
paperCrane 
--
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php
Oops, sorry about that. What you could do is:

GROUP BY object_id

or

GROUP BY object_id, other_field, other_field2, etc

Just don't group by user_id.

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


Re: [PHP-DB] Re: Very complex query

2003-12-11 Thread Muhammed Mamedov
Give me exactly the sample table with data and show what you want there.
I will try to help you.

M.Mamedov

- Original Message - 
From: "Mike U. Petrov" <[EMAIL PROTECTED]>
To: "Muhammed Mamedov" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Thursday, December 11, 2003 10:17 AM
Subject: RE: [PHP-DB] Re: Very complex query


> No, DISTINCT isn't match my purpose cause of it rerurns unique rows but I
> need ONE user_id per one object_id.
>
> Mike U. Petrov
>
>
> -Original Message-
> From: Muhammed Mamedov [mailto:[EMAIL PROTECTED]
> Sent: Thursday, December 11, 2003 11:01 AM
> To: [EMAIL PROTECTED]
> Subject: Re: [PHP-DB] Re: Very complex query
>
>
> You can also DISTINCT command instead.
> UNIQUE command isnot supported by mySQL (at least at MySQL 3.23.41- I am
> using)
>
> Hope this helps,
> M.Mamedov
>
>
> - Original Message -
> From: "Justin Patrin" <[EMAIL PROTECTED]>
> To: <[EMAIL PROTECTED]>
> Sent: Thursday, December 11, 2003 9:52 AM
> Subject: [PHP-DB] Re: Very complex query
>
>
> > Mike U. Petrov wrote:
> >
> > > Hi every1!
> > > Excuse me for maybe offtopic but I need help on mysql database.
> > > I have 4 tables, and here are some important extractions from 'em:
> > > objects{
> > > object_id;
> > > name;
> > > }
> > > users{
> > > user_id;
> > > nick;
> > > date;
> > > }
> > > notes{
> > > user_id;
> > > object_id;
> > > }
> > > object_properties{
> > > object_id;
> > > property_name;
> > > property_value;
> > > }
> > > I need to get EACH object_id from notes with ONLY ONE of corresponding
> > > user_id's. Also for each object I need it's name from objects and
> property
> > > from object_properties where property_name = 'foo'. And for each of
> obtained
> > > user_id I need it's nick and it's date.
> > > Does anyone know how to do it just by one mysql query?
> > >
> > > Thanx...
> > > Mike U. Petrov
> >
> > Use unique(user_id). And please don't reply to a previous post when
> > posting a new threadit screws up threading.
> >
> > --
> > paperCrane 
> >
> > --
> > PHP Database Mailing List (http://www.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
> >
>
>
> ---
> Outgoing mail is certified Virus Free.
> Checked by AVG anti-virus system (http://www.grisoft.com).
> Version: 6.0.545 / Virus Database: 339 - Release Date: 27.11.2003
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>
>


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.545 / Virus Database: 339 - Release Date: 27.11.2003

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



RE: [PHP-DB] Re: Very complex query

2003-12-11 Thread Mike U. Petrov
No, DISTINCT isn't match my purpose cause of it rerurns unique rows but I
need ONE user_id per one object_id.

Mike U. Petrov


-Original Message-
From: Muhammed Mamedov [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 11, 2003 11:01 AM
To: [EMAIL PROTECTED]
Subject: Re: [PHP-DB] Re: Very complex query


You can also DISTINCT command instead.
UNIQUE command isnot supported by mySQL (at least at MySQL 3.23.41- I am
using)

Hope this helps,
M.Mamedov


- Original Message -
From: "Justin Patrin" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, December 11, 2003 9:52 AM
Subject: [PHP-DB] Re: Very complex query


> Mike U. Petrov wrote:
>
> > Hi every1!
> > Excuse me for maybe offtopic but I need help on mysql database.
> > I have 4 tables, and here are some important extractions from 'em:
> > objects{
> > object_id;
> > name;
> > }
> > users{
> > user_id;
> > nick;
> > date;
> > }
> > notes{
> > user_id;
> > object_id;
> > }
> > object_properties{
> > object_id;
> > property_name;
> > property_value;
> > }
> > I need to get EACH object_id from notes with ONLY ONE of corresponding
> > user_id's. Also for each object I need it's name from objects and
property
> > from object_properties where property_name = 'foo'. And for each of
obtained
> > user_id I need it's nick and it's date.
> > Does anyone know how to do it just by one mysql query?
> >
> > Thanx...
> > Mike U. Petrov
>
> Use unique(user_id). And please don't reply to a previous post when
> posting a new threadit screws up threading.
>
> --
> paperCrane 
>
> --
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.545 / Virus Database: 339 - Release Date: 27.11.2003

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

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



Re: [PHP-DB] Re: Very complex query

2003-12-11 Thread Muhammed Mamedov
You can also DISTINCT command instead.
UNIQUE command isnot supported by mySQL (at least at MySQL 3.23.41- I am
using)

Hope this helps,
M.Mamedov


- Original Message - 
From: "Justin Patrin" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Thursday, December 11, 2003 9:52 AM
Subject: [PHP-DB] Re: Very complex query


> Mike U. Petrov wrote:
>
> > Hi every1!
> > Excuse me for maybe offtopic but I need help on mysql database.
> > I have 4 tables, and here are some important extractions from 'em:
> > objects{
> > object_id;
> > name;
> > }
> > users{
> > user_id;
> > nick;
> > date;
> > }
> > notes{
> > user_id;
> > object_id;
> > }
> > object_properties{
> > object_id;
> > property_name;
> > property_value;
> > }
> > I need to get EACH object_id from notes with ONLY ONE of corresponding
> > user_id's. Also for each object I need it's name from objects and
property
> > from object_properties where property_name = 'foo'. And for each of
obtained
> > user_id I need it's nick and it's date.
> > Does anyone know how to do it just by one mysql query?
> >
> > Thanx...
> > Mike U. Petrov
>
> Use unique(user_id). And please don't reply to a previous post when
> posting a new threadit screws up threading.
>
> -- 
> paperCrane 
>
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>


---
Outgoing mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.545 / Virus Database: 339 - Release Date: 27.11.2003

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



RE: [PHP-DB] Re: Very complex query

2003-12-11 Thread Mike U. Petrov
First, sorry my starnge way to post new thread.
Second:
I want to specify some features:
in my table notes I've a lot of user_id's for each object_id and I don't
want to find unique user_id, I only want to find one user_id for each
object_id, so unique(user_id) doesn't match. Do u have any other ideas?

Mike U. Petrov


-Original Message-
From: Justin Patrin [mailto:[EMAIL PROTECTED]
Sent: Thursday, December 11, 2003 10:53 AM
To: [EMAIL PROTECTED]
Subject: [PHP-DB] Re: Very complex query

Use unique(user_id). And please don't reply to a previous post when
posting a new threadit screws up threading.

--
paperCrane 

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

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



[PHP-DB] Re: Very complex query

2003-12-11 Thread Justin Patrin
Mike U. Petrov wrote:

Hi every1!
Excuse me for maybe offtopic but I need help on mysql database.
I have 4 tables, and here are some important extractions from 'em:
objects{
object_id;
name;
}
users{
user_id;
nick;
date;
}
notes{
user_id;
object_id;
}
object_properties{
object_id;
property_name;
property_value;
}
I need to get EACH object_id from notes with ONLY ONE of corresponding
user_id's. Also for each object I need it's name from objects and property
from object_properties where property_name = 'foo'. And for each of obtained
user_id I need it's nick and it's date.
Does anyone know how to do it just by one mysql query?
Thanx...
Mike U. Petrov
Use unique(user_id). And please don't reply to a previous post when 
posting a new threadit screws up threading.

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