[thelist] Sql join problem

David Siedband technique at oceanicsky.com
Thu Dec 9 01:05:45 CST 2004


You need to add the distinct filter like this:

SELECT DISTINCT profile.member_id, members.member_id FROM members JOIN 
profile
WHERE members.username LIKE '%party%' OR members.email_address LIKE
'%party%' AND (profile.category_id = '1' AND profile.content = 'blah')
LIMIT 0, 12
--
David Siedband
generation-xml.com


On Dec 8, 2004, at 6:18 PM, partyarmy wrote:

> Not sure what i'm doing wrong with my join in mysql.
>
> SELECT profile.member_id, members.member_id FROM members JOIN profile
> WHERE members.username LIKE '%party%' OR members.email_address LIKE
> '%party%' AND (profile.category_id = '1' AND profile.content = 'blah')
> LIMIT 0, 12
>
> so that statement should select the 'member_id' from either the
> profile or members tables where the username or email_address columns
> are LIKE %party% and where the 'category_id' and 'content' match up.
> limit of 12 for display.
>
> the problem is if there is less than 12 results i get the result set
> repeated. is there not a way to select from two different tables and
> merge the results in mysql. does someone have an easy tutorial that i
> could follow. i tried the manual, but it's too confusing for me.
>
> thanks, codi lechasseur
> -- 
>
> * * Please support the community that supports you.  * *
> http://evolt.org/help_support_evolt/
>
> For unsubscribe and other options, including the Tip Harvester
> and archives of thelist go to: http://lists.evolt.org
> Workers of the Web, evolt !
>



More information about the thelist mailing list