Sorry , I didn't read the second line

SELECT P.Id FROM Person as P WHERE P.Name LIKE 'John' AND P.Id IN (SELECT
PersonId WHERE PersonID = P.Id)

Try these


2008/9/8 Hernan Anskaitiene <[EMAIL PROTECTED]>

> SELECT Id FROM Person WHERE Name LIKE 'John'
>
> Is that what you need?
>
> 2008/9/8 wawa <[EMAIL PROTECTED]>
>
>
>> I have 2 tables, say, "Person" and "Hobbies". Person can have zero or
>> more hobbies. Here's what the table structure looks like:
>>
>> Person  (Id , Name)
>> Hobbies (Id, PersonId, HobbyName)
>>
>> How do I get all the Person->Id where Person->Name is, say, 'John'
>> regardless if the record has a hobby?
>> >>
>>
>
>
> --
> Hernán Anskaitiene
>



-- 
Hernán Anskaitiene

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "PHP 
& MySQL" group.
To post to this group, send email to [EMAIL PROTECTED]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/phpmysql?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to