Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

84 users online



Too many results from mysql query

Too many results from mysql query

Currently viewing this thread: 1 (0 members and 1 guests)


rocky2083

rocky2083

Neverside Newbie
Status: Offline!

Too many results from mysql query

Hey all,

I want to do a query for programs that are tied to currently logged user and for programs that are accessible to all users in general. Now I use this query

PHP:

<?php

SELECT 
                data
.iddata.titledata.file 
              FROM 
                data
access 
              WHERE
                data
.id access.progid 
              
AND 
                
access.userid '{$_SESSION['ses_nuserid']}'
              
OR
                
data.exposure 1
              ORDER BY 
                added

?>

I do get the particular programs but the query also throws out too many results of program accessible to all users (TIMES all rows In access table). Can somebody please show me where is my problem. I'm also adding a pic so you can see what im talking about (INFOKREDITI should be shown only once)

Attachments:

problem.jpg problem.jpg (Download) 30.05 Kb, 84 views

___________________

Right Or Wrong I'm Still The Boss

BigToach

BigToach

Neversidian
Status: Offline!

is infokredit in there 2 times? try using a group by data.title or select distinct values

___________________

Neverside Development Director
PHP Snippets
BigToach.com - IT WORKS, TOACHY!

rocky2083

rocky2083

Neverside Newbie
Status: Offline!

THANK YOU BigToach!! Distinct worked like a charm. And no infokredit is not in DB two times without Distinct the query showed infokredit as many times as there were rows in access table.

___________________

Right Or Wrong I'm Still The Boss

BigToach

BigToach

Neversidian
Status: Offline!

I dont think distinct is technically the correct way for it to work, but without more info on your db design and stuff its hard to know the correct way. But if it works, dont break it trying to fix it.

___________________

Neverside Development Director
PHP Snippets
BigToach.com - IT WORKS, TOACHY!

Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0174 seconds.