On 14-Jun-01 brainheap wrote:
> hi ppl!
>
> I have two consequent queries
>
> "select @g1=user from user_space where connects>10"
> and
> "select connect_time from connects where user=@g1"
>
What if there are more than 1 user(s) where connects >10, or none ?
> To prevent misunderstanding I say that I don't want to use joining as in
> my case tis very slow operation.
>
Unless something is seriously wrong with the normalization, it looks like this
should be a very fast query:
SELECT a.usr, a.connects as connects, b.connect_time
FROM user_space as a, connects as b
WHERE connects >10 and a.user=b.user ...
I'm assuming user_space.user is a primary key, you have an index
on connects.user (, plus an index on user_space.connects would help).
> My question is:
>
> when I proceed these two queries using mysql_query() I get success
> but when I get the result using mysql_store_result() and
> mysql_fetch_row() I get the result for the first query.
>
> Does that mean that I need to get both results from server?
> If so - can I avoid fetching useless data and skip getting first query
> result and get only the next one?
>
Anyhow, do the query, test the result & discard:
$query="select @g1=user from user_space where connects>10";
$rslt = mysql_query($query);
if ($rslt) {
$dontcare = mysql_numrows($rslt); // discard
$query="select connect_time from connects where user=@g1";
$rslt=mysql_query($query);
if ($rslt) {
while ($row=mysql_fetch_object($rslt)) {
... do foobarbaz ...
}
}
}
Regards,
--
Don Read [EMAIL PROTECTED]
-- It's always darkest before the dawn. So if you are going to
steal the neighbor's newspaper, that's the time to do it.
---------------------------------------------------------------------
Before posting, please check:
http://www.mysql.com/manual.php (the manual)
http://lists.mysql.com/ (the list archive)
To request this thread, e-mail <[EMAIL PROTECTED]>
To unsubscribe, e-mail <[EMAIL PROTECTED]>
Trouble unsubscribing? Try: http://lists.mysql.com/php/unsubscribe.php