This topic is locked
[SOLVED]

 understanding Join....

5/23/2011 10:58:32 AM
PHPRunner General questions
M
mickna author

Hi there,
I try to figure out how joining works and I'll guess I have a problem understanding a simple joining of two tables.
In my project I have two separate tables for the users, as I like to store necessary user datas (login, passwd, Email) in one table and additional infos (birthday, address, etc.) in a second one
TABLES:

users (ID, userName, passwd, Email)

userdetails (ID, userName, address, birthday, skype, ...)
If I want show the email field from 'users' at list view from 'userdetails_list.php' I use a inner join and join users.email to the userdetails table. No big deal.

(INNER JOIN users ON userdetails.userName = users.userName)
However, in edit mode from "userdetails" I can not change the email address (Record was not edited. Unknown column 'users.userEmail' in 'field list')
a) So my understanding from joining is now: You can join different tables and display the fields of them. But you can not edit the fields as mySQL still refers to the "main table" (No column with "Email" in userdetails and MySQL did not refer back to the joined table "users" from where the column Email came from....)

<img src='https://asprunner.com/forums/file.php?topicimage=1&fieldname=question&id=17071&image=1&table=forumtopics' class='bbc_emoticon' alt='B)' /> if so, how can I made one edit view with fields from different tables?
thx,

mickna

Sergey Kornilov admin 5/23/2011

SQL and database theory do not support updating more than one table at once.
If relation between Users and UserDetails table is always one-to-one you should combine these two tables into one which will solve your issue. In other word if User is a single entity splitting it into two tables won't give you any benefits.

M
mickna author 5/23/2011

Thank you so much Sergey!
Best mickna