SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Sep 2000
    Location
    Ontario, Canada
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    select from multiple tables

    I'm messing around with a content management system called mArticle and basically what I'd like to do is create additional tables. I have some of it working but when it comes to the validation page where it looks to the 2 category tables, everything falls apart.

    here's the select statement that I have so far. I'm getting a syntax error.

    $unedited=$DB_ma->query("SELECT articlemain.*, articlereviews.* FROM articlemain, articlereviews WHERE (articlemain.isapproved=0) OR (articlereviews.isapproved=0) ORDER BY dateline DESC");

    All its supposed to do is look to the 2 tables and pick out and display the ones with "isapproved=0".

    Any ideas as to why I'm getting the syntax error. I attempted to ask the original author of the script about modifications but I don't think he's around anymore.

    Any suggestions are appreciated!
    Jason Dulberg
    Extreme MTB
    http://extreme.nas.net

  2. #2
    SitePoint Enthusiast
    Join Date
    Feb 2001
    Posts
    58
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I would like to see the table structure. What you are attempting is a join query, but there is now where clause that tells the query upon which columns to perform the join. It should probably look something like this.

    $unedited=$DB_ma->query("SELECT articlemain.*, articlereviews.* FROM articlemain, articlereviews WHERE (articlemain.ID = articlereviews.articleID) and ((articlemain.isapproved=0) OR (articlereviews.isapproved=0)) ORDER BY dateline DESC");

    Assuming that there is a column in the articlereviews table name articleID that specifies that ID of the article for which that review was written.
    Marty H.

  3. #3
    SitePoint Addict
    Join Date
    Sep 2000
    Location
    Ontario, Canada
    Posts
    320
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    articlemain and articlereviews are seperate article categories so would they need to match on ID?

    Basically, I just want to do is list all from articlemain/reviews where isapproved=0. isapproved is common in both categories.

    Thanks for your help on this!
    Jason Dulberg
    Extreme MTB
    http://extreme.nas.net


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
  •