Reply
I am have trouble with the equi-join and the where clause which does not seem to exclude records that do not meet the filter condition
Old 05-19-2006, 11:50 PM I am have trouble with the equi-join and the where clause which does not seem to exclude records that do not meet the filter condition
Junior Talker

Posts: 3
I am haveing trouble with using embeded MYSQL if i stuff a numeric value in my $myid array and try to pass it to my equi-join below it is given me back in the result set all the rows but you can see i have added the AND " . TABLE_PREFIX . "groups_members.userid = '" . $myid[0] . "' to my equi- join and the AND does not seem to be filtering the result set by only retuning the records after tables have been joined only the records where the userid = 1 -Please see what i might be doing wrong.


$myid = array();
$myid[0] = 1;
echo "<br>";
echo $myid[0];


$groupname_result = $db->query_read("select " . TABLE_PREFIX . "groups_members.groupid, " . TABLE_PREFIX . "groups_groups.groupname
from " . TABLE_PREFIX . "groups_members, " . TABLE_PREFIX . "groups_groups
where " . TABLE_PREFIX . "groups_members.groupid = " . TABLE_PREFIX . "groups_groups.id AND " . TABLE_PREFIX . "groups_members.userid = '" . $myid[0] . "'
order by " . TABLE_PREFIX . "groups_members.level DESC");

$groups_count = $db->num_rows($groupname_result);
echo "<br>";
echo $groups_count . ' the number of rows of groups ';
echo "<br>";


THANKS

Note: The MYSQL_has been striped out of the functions they are the same functions.
Whitejeep is offline
Reply With Quote
View Public Profile
 
When You Register, These Ads Go Away!
Old 05-20-2006, 06:42 AM Re: I am have trouble with the equi-join and the where clause which does not seem to exclude records that do not meet the filter condition
chrishirst's Avatar
Super Moderator

Latest Blog Post:
Am I impressed or what?
Posts: 14,831
Location: Blackpool. UK
show the query after it has been built, so we see the SQL select query NOT the PHP code

BTW there is no JOIN in there
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Old 05-20-2006, 10:58 PM Re: I am have trouble with the equi-join and the where clause which does not seem to exclude records that do not meet the filter condition
Junior Talker

Posts: 3
it is a syntaic issue on the where clause

I add this line to the end of my existing where clause did this not make it a

equi - join

AND " . TABLE_PREFIX . "groups_members.userid = '" . $myid[0] . "'

Do not worry about the " . TABLE_PREFIX . " that is need before the name of every table and not the issue.

Note: If i remove the line
AND " . TABLE_PREFIX . "groups_members.userid = '" . $myid[0] . "'
then it is a equ- join i have tested it in the client mysql and if I append to the end of the where clause in the mysql client I get the correct data.

I the mysql client i add this to the edn of the where clause groups_members.userid = 1
that works just fine in the mysql client and if i do this it also works fine
groups_members.userid = '1'

I both cases it only returns the records that are userid 1 only in the result set.

but in my PHP it returns all the joined records even one that are not userid 1

Please look at the syntac and tell me mybe what i should do. THANKS
Whitejeep is offline
Reply With Quote
View Public Profile
 
Old 05-21-2006, 04:59 AM Re: I am have trouble with the equi-join and the where clause which does not seem to exclude records that do not meet the filter condition
chrishirst's Avatar
Super Moderator

Latest Blog Post:
Am I impressed or what?
Posts: 14,831
Location: Blackpool. UK
Still can't see the query after it has been built.

That is where the error will show up. Cannot see it looking at some variables that we have no way of knowing IF they contain the right values or not.

As you point out yourself, it works when you hardcode the values which should be telling you that the error is in the PHP variable NOT the SQL query
__________________
Chris. ->> Links are advertising NOT optimising!! <<-
Indifference will be the downfall of mankind, but who cares?
Code Samples | People Counting System
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to I am have trouble with the equi-join and the where clause which does not seem to exclude records that do not meet the filter condition
 

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML

 


Page generated in 0.12399 seconds with 12 queries