Bluehost.com Web Hosting $6.95

Mysql query optimization? Please help me

This is a discussion on Mysql query optimization? Please help me within the MySQL Database forums, part of the Database Forums category; Here is part of the structure of my current database: table permissions: id permission table groups id name table groups_permissions ...


Go Back   Usenet Forums > Database Forums > MySQL Database

FAQ Members List Calendar Search Today's Posts Mark Forums Read
  #1 (permalink)  
Old 02-08-2007
Vu Nguyen
 
Posts: n/a
Default Mysql query optimization? Please help me

Here is part of the structure of my current database:
table permissions:
id
permission

table groups
id
name

table groups_permissions
id_group
id_permission

table groups_users
id_group
id_user

table entries:
id
name

table entries_groups
id_group
id_entry

One user can belong to many groups, one group can control many
entries. Given a list of entries and the user_id, I need to check if
that user can control those entries, and if possible return a list of
entries that the user can/can't not control.

Currently I'm using the query below, if the returned COUNT doesnt
match the number of entries given then the user doesnt have accesst to
all the give entry. Is there any better way to do this?
SELECT COUNT(*)AS COUNT FROM entries_usergroups, users_usergroups,
permissions_usergroups, permissions
WHERE entries_usergroups.entry_id IN ($entry_list)
AND users_usergroups.usergroup_id = entries_usergroups.usergroup_id
AND users_usergroups.user_id = $user_id
AND permissions_usergroups.usergroup_id =
entries_usergroups.usergroup_id
AND permissions.id = permissions_usergroups.permission_id
AND permissions.name = '$permission';


Thank you.

Reply With Quote
Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

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




All times are GMT +1. The time now is 06:18 AM.


Powered by vBulletin® Version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO 3.0.0