Advanced Search

Results 1 to 2 of 2

Thread: how to get rows??

  1. #1
    Join Date
    May 2009
    Posts
    11
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default how to get rows??

    HI,
    In mysql, I have 2 tables friends, my_page.

    friends
    --------
    id int(11)
    username char(40)
    person char(40)
    type enum('Friend','Blocked')

    id username person type
    ------------------------------------------------------
    13 king_nothing Musechild Friend
    587 MrRogue ammo Friend
    17 Honey MrRogue Friend


    my_page
    --------
    id int(11)
    username varchar(30)
    page_owner varchar(30)
    date_posted datetime
    text text

    id username page_owner text date
    ------------------------------------------------------------
    4 Honey MrRogue PHP 2010-06-11 12:30:18
    5 ammo MrRogue java 2010-06-08 10:54:52
    6 mobster ammo both 2010-06-12 21:20:14
    7 ammo Wizkid wrong 2010-06-12 21:39:29
    8 Honey ammo show 2010-06-12 22:28:52

    friends table tells freinds of each member,
    say MrRogue is friend of ammo, Honey.Note that MrRogue can come in either username/person field, not necessarily to be in username field.

    Now I want rows from my_page where my_page.username, my_page.page_owner both are friends of MrRogue, like

    8 Honey ammo show 2010-06-12 22:28:52

    Thanks in advance!!!!
    Regards

  2. #2
    Join Date
    Mar 2006
    Location
    Illinois, USA
    Posts
    12,154
    Thanks
    260
    Thanked 690 Times in 678 Posts

    Default

    Can you just use "OR":
    ...WHERE `field1` = $value OR `field2` = $value
    Daniel - Freelance Web Design | <?php?> | <html>| espa˝ol | Deutsch | italiano | portuguŕs | catalÓ | un peu de franšais | some knowledge of several other languages: I can sometimes help translate here on DD | Linguistics Forum

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •