View Full Version : one table in 2 sql statements
kairog
08-02-2008, 06:35 PM
Hi everyone, I'm trying to combine two sql statements into just one but to no avail.
Basically, I'm trying to get values from the same table
first query: I try to get the referrer ID
select referrerID
from members
where memberID=8
then execute another query:
select *
from members
where memberID="whatever the answer from the first query
Any better idea? Thanks
oesxyl
08-02-2008, 06:49 PM
try something like:
select * from members
where memberID in (select refererID from members where memberID=8)
regards
kairog
08-02-2008, 07:03 PM
I tried that already...but still not working
my Mysql version is 5.0.45.
Probably Join may do the trick...but I'm not good at join
any idea?
CFMaBiSmAd
08-02-2008, 07:15 PM
Based on your statement of what you want, that should have worked. What exactly did it do that was not correct?
You need to provide an example of what your data is and what the expected results should be.
oesxyl
08-02-2008, 07:16 PM
I tried that already...but still not working
my Mysql version is 5.0.45.
Probably Join may do the trick...but I'm not good at join
any idea?
I just test it and it work, I have 5.0.30.
I guess is a problem with your data, that if "not working" means there is no output.
regards
kairog
08-02-2008, 07:24 PM
Thanks both of you guys...I will reanalyze my data.
yes CFMaBiSmAd you are right...it should work and I believe it should. But something is really wrong.
Thanks to you oesxyl as well
oesxyl
08-02-2008, 07:28 PM
Thanks both of you guys...I will reanalyze my data.
yes CFMaBiSmAd you are right...it should work and I believe it should. But something is really wrong.
Thanks to you oesxyl as well
look to the output of your each query and post output to see if we can help. I guess this way will find why puting toghether don't work.
regards
kairog
08-02-2008, 07:37 PM
I examined my table and I forgot that I renamed one of the fields in the table.
it's working now.
Thanks to you oesxyl and CFMaBiSmAd
many thanks
guelphdad
08-03-2008, 09:01 AM
that's why posting the actual error message is helpful, then folks could look at it and help you pinpoint the problem more quickly.
vBulletin® v3.8.2, Copyright ©2000-2009, Jelsoft Enterprises Ltd.