0

Ok, ran into some problems in one of the newsgroups so thought here would be an excellent place to turn. Actually have only posted once or twice here and was real surprised at the pleasantness of the answers. So.

You have bOrders and bUser listed respectivly below.

In the simplest example of what I am looking for, the system comes up with
an email address which I use in two steps:

Get the users userid (step 1)
Get all orderids for that userid (step 2)

What I am looking to do is just to do it all in one step. So using examples on the web I tried

Which came out to:

select orderid from bOrders where userid IN (select userid from email = 'John@abc.com');

That gave me the error:

ERROR 1064: You have an error in your SQL syntax near 'select userid from email = 'John@abc.com')' at line 1

Now of I run it as

select orderid from bOrders where userid IN ('11111');

It works, so it leads me to believe that my syntax in the ( ) is off. Would so appreciate any help. I don't think I need to get as complex as a join thing here, and I would swear I have done this before.

Then again, I can't seem to redo it.

Thanks ahead, as always.

bOrder
+--------+---------+
| userid | orderid |
+--------+---------+
| 11111 | aaaaa |
| 11111 | bbbbb |
| 11111 | ccccc |
| 22222 | ddddd |
+--------+---------+
4 rows in set (0.00 sec)

bUsers
+--------------+--------+
| email | userid |
+--------------+--------+
| John@abc.com | 11111 |
| mary@nbc.com | 22222 |
| dick@cbs.com | 33333 |
+--------------+--------+

3
Contributors
3
Replies
4
Views
9 Years
Discussion Span
Last Post by vssp
0

Before anyone responds, looks like I wasn't running the proper version of MySQL. Will know in a bit if that's the problem.

1

select orderid from bOrders where userid IN (select userid from email = 'John@abc.com'); Thats wrong. You are missing where clause.. :) select orderid from bOrders where userid IN (select userid from bUsers where email = 'John@abc.com'); Cheers,
Nav

Votes + Comments
shabbaaaaash :D
This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.