MYSQL JOIN SELECT Statment - omit duplicated

Posted by mouthpiec on Stack Overflow See other posts from Stack Overflow or by mouthpiec
Published on 2010-05-07T14:44:29Z Indexed on 2010/05/07 14:48 UTC
Read the original article Hit count: 253

Filed under:
|
|
|

Hi,

I am tying to join the following 2 queries but I am having duplicated .... it is possible to remove duplacted fro this:

(
SELECT bar_id, bar_name, town_name, bar_telephone, 
        (subscription_type_id *2) AS subscription_type_id
FROM bar, sportactivitybar, towns, subscriptiontype
WHERE sport_activity_id_fk =14
    AND bar_id = bar_id_fk
    AND town_id = town_id_fk
    AND subscription_type_id = subscription_type_id_fk
)
UNION 
(
SELECT bar_id, bar_name, town_name, bar_telephone, 
         subscription_type_id
FROM bar, towns, subscriptiontype
WHERE town_id = town_id_fk
    AND subscription_type_id = subscription_type_id_fk
)
ORDER BY subscription_type_id DESC , RAND( )

Please note that I need to omit those duplicates that will have a lower subscription_type_id

© Stack Overflow or respective owner

Related posts about mysql

Related posts about join