Jump to content

Nested select command


pentan

Recommended Posts

Can anyone tell me what's wrong with this command? I keep getting an error messsage.

select distinct(rRR) from RRInventory where rSite=(select rSite from RRInventory where rIndex='720');

Both select statments work fine alone but together the die. I looked in the manual and I must be missing something but I can't see it.

Michael
Link to comment
Share on other sites

maybe I'm missing something, but you make it seem like they are from the same table which may be your problem... I would change it to say

[code]SELECT DISTINCT(rRR) FROM RRInventory where rIndex='720';[/code]

because whats the point in select rSite from the same table if you are never going to use it?

[!--quoteo(post=347697:date=Feb 20 2006, 01:34 PM:name=pentan)--][div class=\'quotetop\']QUOTE(pentan @ Feb 20 2006, 01:34 PM) [snapback]347697[/snapback][/div][div class=\'quotemain\'][!--quotec--]
Can anyone tell me what's wrong with this command? I keep getting an error messsage.

select distinct(rRR) from RRInventory where rSite=(select rSite from RRInventory where rIndex='720');

Both select statments work fine alone but together the die. I looked in the manual and I must be missing something but I can't see it.

Michael
[/quote]
Link to comment
Share on other sites

It is from the same table. Is it going to die because of that? And I can't used the shortened version. The rIndex refers to a single line in the table. That line has a site field (rSite). I want to use that value to pull all the lines out of the table that have the same site value. Or am I missing a really easy way to do this?
Link to comment
Share on other sites

The error I'm getting is:

mysql> select distinct(rRR) from RRInventory where rSite=(select rSite from RRInventory where rIndex='720');
ERROR 1064: You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near 'select rSite from RRInventory where rIndex='720')' at line 1
mysql>


I believe my versino is 4.0.22

Thanks!
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.