4 Replies - 9900 Views - Last Post: 21 May 2002 - 01:29 PM

#1


Reputation: 0

MySQL nested SELECTS using PHP

Posted 21 May 2002 - 12:59 PM

I'm trying to nest a SELECT in a query and it won't seem to work. I thought I read that it will work on PHP.net or MySQL.com but I can't find it now.
here is what I am trying for -
SELECT item.id FROM item JOIN store WHERE item.id NOT IN (SELECT itemId FROM store)

As a test I ran this and it works fine:
SELECT item.id FROM item JOIN store WHERE item.id NOT IN (1,2,3,5)

so the issue is in the nested select.

Thanks,
Hoopster


Is This A Good Question/Topic? 0

Replies To: MySQL nested SELECTS using PHP

#2 Cookie Mobster  Icon User is offline

  • nooneenooneenooonee
  • member icon

Reputation: 7
  • View blog
  • Posts: 4,730
  • Joined: 12-October 01

Re: MySQL nested SELECTS using PHP

Posted 21 May 2002 - 01:12 PM

Try:
SELECT item.id FROM item JOIN store WHERE item.id NOT IN store.itemId

Cheers Sam

Was This Post Helpful? 0
  • +
  • -

#3 fyrestorm  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 10
  • View blog
  • Posts: 3,113
  • Joined: 04-April 02

Re: MySQL nested SELECTS using PHP

Posted 21 May 2002 - 01:27 PM

Hoopster, currently subselects are not a feature in mysql.

But if you look here it explains that it's a feature that's being developed into mySQL version 4.1

Was This Post Helpful? 0
  • +
  • -

#4


Reputation: 0

Re: MySQL nested SELECTS using PHP

Posted 21 May 2002 - 01:28 PM

Still got a SQL error, I believe that NOT IN needs to be in parens - NOT IN (store.itemId), but when I tried that it returned everything in store several times over.

Hoopster

Was This Post Helpful? 0

#5 fyrestorm  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 10
  • View blog
  • Posts: 3,113
  • Joined: 04-April 02

Re: MySQL nested SELECTS using PHP

Posted 21 May 2002 - 01:29 PM

Here's a possible work around that I found:

http://www.faqts.com.../aid/253/fid/13

Was This Post Helpful? 0
  • +
  • -

Page 1 of 1