You are here: Re: Help with query - strange behaviour « PHP SQL « IT news, forums, messages
Re: Help with query - strange behaviour

Posted by rukkie on 12/19/06 15:45

Thanks for your suggestion, but I don't think it solves my problem.
Let 's take for example :

+-------+------+
|col1 | col2|
+-------+------+
A
B C
D
C B
A
E F


Then the result of the query should be A,B,C,D,E and F.

With the code I'm using I get, for some reason or another, for example
2 times A, although I only ask for distinct values ....
And moreover, if I change the select query to only SELECT DISTINCT col1
FROM ....I get the A value only once. Using SELECT DISTINCT col1, col2
FROM ... I get the value twice, although A does not appera in the col2

Using the proposed suggestion from you, will give me BC and CB as
distinct (due to the CONCAT), but the values in the cols are the same
.....

I hope this clarifies a bit what the problem is ...

J.O. Aho schreef:

> rukkie wrote:
> > Some addition :
> >
> > the commands used in PHP to see the result are :
> >
> > while($nt=mysql_fetch_array($result5)){
> > if ($nt[col1] <> "") {
> you should use empty() and not <>
>
>
> > As a result I fsee some double entries, which is not the idea .... Very
> > strange behaviour or very stupid programming of me ?
>
> >> I'm using this query :
> >>
> >> $query5="SELECT DISTINCT col1,col2 FROM db WHERE (col1<>\" \") ORDER BY
> >> col1,col2 asc";
>
> What about:
> SELECT DISTINCT CONCAT(col1,col2) FROM db ORDER col1,col2 asc
>
>
> --
>
> //Aho

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация