Computing.Net > Forums > Programming > Mysql help

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Over 90% answered within 24 hours! Click here to start participating now! Also, be sure to check out the New User Guide.

Mysql help

Reply to Message Icon

Name: Nirav
Date: November 14, 2002 at 13:12:40 Pacific
OS: win98
CPU/Ram: p3
Comment:

Hi:
Im doing a project using PHP & MYSQL.
i have a question regarding that. i have 2 tables in my database EMPLOYEE

TABLE 1: EMP_ID (PK), PASSWORD (ATTRIBUTES)
TABLE 2: EMP_ID (PK),EMP_NAME,.......ETC

IS THAT POSSIBLE? I MEAN CAN MY 2 TABLES HAVE SAME PRIMARY KEY (EMP_ID IS THE PK FOR 2 TABLES)... ANY HELP WOULD BE GREATLY APPRECIATED.

THANX
NIRAV



Sponsored Link
Ads by Google

Response Number 1
Name: Don Arnett
Date: November 14, 2002 at 14:08:48 Pacific
Reply:

That's not a problem since they are separate tables. The primary key applies only to the table that it is in.

If you do a query that involves both tables, you will have to differentiate which table's EMP_ID you mean.

Let's say that you wanted to get the password and employee name for a given id:

select emp_name, password
from table1, table2
where table1.emp_id = table2.emp_id
and table1.emp_id = "12345";


You don't HAVE to put the table name on 'emp_name' or 'password' since they exist in only one of the tables. Many times I do add the table name when more than one table is involved for documentation purposes.


0
Reply to Message Icon

Related Posts

See More







Post Locked

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: Mysql help

php/mysql help! www.computing.net/answers/programming/phpmysql-help/8007.html

PHP MySQL Help needed www.computing.net/answers/programming/php-mysql-help-needed/17588.html

Help with: php, MySQL, database www.computing.net/answers/programming/help-with-php-mysql-database/8422.html