SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Need Dual Database Query

    I have a content management system which displays dynamic URL's on the home page (mysite) and the home pages of several sections (mysite/About, mysite/Reference, etc.). One problem is that the sectional home pages themselves aren't accounted for. For example, mysite/About/Search works (because Search matches a value in my database). But mysite/About is in limbo.

    So I think one solution is to link the sectional home pages themselves with my home page CMS. The home page currently displays the names of places...

    mysite/Arizona
    mysite/Africa, etc.

    It uses the following query:

    PHP Code:
    $Geog mysql_fetch_assoc(mysql_query("SELECT GG.IDArea, GG.Name GName, GG.Type,
     GG.IDParent, GG.Parent, GG.IDReg, GG.Pre, GG.Post, GGP.IDArea, GGP.IDParent2, NN.IDArea, NN.GNick
     FROM gw_geog GG
     LEFT JOIN g_nicknames NN ON NN.IDArea = GG.IDArea
     LEFT JOIN gw_geog_par2 GGP ON GGP.IDArea = GG.IDArea
     WHERE GG.Name LIKE '
    $MyName'")); 
    So I created a second table (g_home) that lists the names of the various sections, such as About and Reference. Now I need to write a script that combines my original query with a query that recognizes section names (e.g. mysite/Reference).

    Can anyone tell me how to do this? I tried the following, without success:

    PHP Code:
    $Geog mysql_fetch_assoc(mysql_query("SELECT GG.IDArea, GG.Name GName, GG.Type,
     GG.IDParent, GG.Parent, GG.IDReg, GG.Pre, GG.Post, GGP.IDArea, GGP.IDParent2, NN.IDArea, NN.GNick
     FROM gw_geog GG
     LEFT JOIN g_nicknames NN ON NN.IDArea = GG.IDArea
     LEFT JOIN gw_geog_par2 GGP ON GGP.IDArea = GG.IDArea
     WHERE GG.Name LIKE '
    $MyName'
     OR SELECT URL FROM g_home GH
     WHERE GH.URL LIKE '
    $MyName'")); 
    Thanks.

  2. #2
    Follow Me On Twitter: @djg gold trophysilver trophybronze trophy Dan Grossman's Avatar
    Join Date
    Aug 2000
    Location
    Philadephia, PA
    Posts
    20,578
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You need to join this table to the others as well. You can't just throw a new table in after the WHERE clause of the query, doesn't work like that. The MySQL forum is more appropriate if you need someone to write it.

  3. #3
    Non-Member
    Join Date
    Jan 2004
    Location
    Seattle
    Posts
    4,328
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks.


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
  •