SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    SitePoint Enthusiast auchrins's Avatar
    Join Date
    Jul 2003
    Location
    New York, NY
    Posts
    87
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Why doesnt this query work?

    SELECT *
    FROM NEWSLETTERS
    WHERE PARENT_ID =
    (SELECT PARENT_ID FROM NEWSLETTERS WHERE NEWS_ID = '4');

    It works fine in the SQL view of Access, but gives me a syntax error if I put it in PHPMyAdmin...

  2. #2
    SitePoint Zealot newspire's Avatar
    Join Date
    Mar 2005
    Location
    Houston, TX
    Posts
    118
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Check your version of MySQL. You will need MySQL 5 to do subqueries.

  3. #3
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    you don't need a subqery for that query.
    Code:
    SELECT *
    FROM NEWSLETTERS
    WHERE NEWS_ID = '4';

  4. #4
    SitePoint Wizard guelphdad's Avatar
    Join Date
    Oct 2003
    Location
    St. Catharines, ON Canada
    Posts
    1,706
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by newspire
    Check your version of MySQL. You will need MySQL 5 to do subqueries.
    Version 4.1 supports subqueries.

  5. #5
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,017
    Mentioned
    53 Post(s)
    Tagged
    2 Thread(s)
    Quote Originally Posted by longneck
    you don't need a subqery for that query.
    oh?

    well, one might be able to do it without a subquery, but your solution isn't it

    the query in post #1 finds all rows that have the same parent as row 4

    your query merely returns row 4

    not the same thing at all
    r937.com | rudy.ca | Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  6. #6
    reads the ********* Crier silver trophybronze trophy longneck's Avatar
    Join Date
    Feb 2004
    Location
    Tampa, FL (US)
    Posts
    9,854
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by r937
    not the same thing at all
    *smack*

    *thud!!!*


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
  •