RE: query

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Ideally, you would have 3 tables like so...


Projects(with one record per project)
---------
projectID	|ProjectName|	etc...
1		my project
2		another project


Users(with one record per user)
-------
userID|	userName|	etc...
123		Joe Blow
124		Mary Jane


ProjectsVerified
----------------
projectID|	userID
1		123
1		124
2		124


In this example, Joe has verified my project only.  Mary Jane has verified
"my project" and "another project".

Whether you use my database or yours, you will need to use SQL's JOIN syntax
to properly extract the information you are looking for.  Read up on SQL and
JOIN types, (LEFT, INNER, OUTER etc.).  They are tricky at first but well
worth it once you figure out what is going on.  Or just repost, and someone
will help you out with it.

J


-----Original Message-----
From: Natividad Castro [mailto:ncastro@cots.com] 
Sent: Wednesday, December 04, 2002 9:35 AM
To: php-db@lists.php.net
Subject:  query


Hi to all,
I'm working in a system where users can post projects. Other users will
verify those projects. What I'm trying to do is once a user verify a project
he/she cannot view it anymore, but I want to keep it available for the other
users that haven't verified it.

I have two tables project and user_verified. On project table I keep all the
projects that users post. On user_verified I keep users who already verified
for a project.

These are the fields for user_vefified table

project_id, username, verified

Everytime a user verifies a project I insert a new record to the
user_verified table.

This the query, but it doesn't work.
It selects the same record from the two tables. e.g. if the records exist
twice on the user_verified table and one on the project table, it will
display three records when I run the the following query:

$sql = "SELECT project.project_id, project.project_name,
project.project_desc FROM project, user_verified
       WHERE project.username <> user_verified.username AND project.username
<> '$PHP_AUTH_USER' AND project.category='$category')";

any help is greatly apprecciate it

Thanks in advance
Nato


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux