Re: SQL prob

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



use DISTINCT?

On Sunday 30 January 2005 12:51 pm, Bobo Wieland wrote:
> Anyone that can help me with this one? I want this SQL-statement to
> retrive only distinct values from the original table column named (not
> the AS stuff)
>
> (
> SELECT * , namn_2 AS sec_namn, namn_1 AS one
> FROM sortiment
> WHERE namn_1 LIKE 'H%'
> )
> UNION (
>
> SELECT * , UPPER( namn_2 ) AS sec_namn, namn_2 AS one
> FROM sortiment
> WHERE namn_2 LIKE 'H%'
> AND SUBSTRING( namn_2, 1, 1 ) LIKE BINARY 'H'
> )
> ORDER BY one
> LIMIT 0 , 10
>
> this will return, for example, the following row twice where (in the
> original table)
> namn_1 = "Humulus lupulus"
> namn_2 =  "Humle"
>
> the two rows are identical except for the "sec_namn" and "one" created
> by the query. They are set to:
> sec_namn                  one
> HUMLE                    Humle
> Humle                        Humulus lupulus
>
>
>
>
> _bobo wieland _ dev@xxxxxxxxxxxxx _
> winamp >> Not playing anything right now...

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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux