JOINing tables with different number of rows

  • Hi all!

    I have a problem. I'm trying to make a small search engine. I have two tables like this:

    memOnline

    memID

    memSearch

    memID

    Gender

    Age

    ...

    As you can see it's easy to make a query that searches only for the members that are online just by JOINing the two tables. But how can I make a query that returns a boolean whether or not the member is online?

    Hope you understood my question...

    Thanks!

    /Tomi

  • Try this

    select s.memID, s.Gender, s.Age,

    case when o.memID is null then 0 else 1 end as Online

    from memSearch s left join memOnline o on s.memID = o.memID

    Edited by - paulhumphris on 11/28/2002 09:34:16 AM

  • ....sorry, had to edit comment above to LEFT join instead of INNER join.

  • Thank you!

    Exately what I meant.

    /Tomi

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply