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 |
+--------------+--------+

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

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

commented: shabbaaaaash :D +4

hi friends
Try this syntax
Select * from bOrders b1 , bUsers u1 where b1.userid=u1.userid and u1.email= 'john@abc.com'

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.