Friday 15 January 2010

mysql - How to join many tables ? -


How do I JOIN tables are very confusing at work I did anything good to every possible document Tried without reading.

I am trying to do a large SELECT on different tables to get all the data of a specific user. The questions below look for the loop forever without any good results.

Can anyone tell the easiest way to do JOIN correctly? Thank you

  select user.id_user, name, surname, email, password, status, phone, address, city, ZIP_CODE, company_name, cf, piva, public, icon, description, comment, Web, Facebook_id, facebook_token, twitter_id, twitter_token, linkedin_id, linkedin_token, ip, date, link, confirmation, newsletter, legal_validation user, user_addfields_anagraphic, user_addfields_legal, user_addfields_public, user_addfields_social, user_registration WHERE user.id_user = '43534534534'  < / Pre>  

You are not joining tables in any meaningful way, Ends with the foot, which is where every line joins every other line.

You have to get the columns in each table which allows each other to be related (this is a relational database with which we are working).

So if you want to know which employees are in a department, then you will do something like

  select the name, join Employee Employee Emp Partment D at De Emp.dept_no = d.dept_no where dept.description = "sale"   

is the key to recognizing the condition included in the condition - it specifies how you have a table The content is related to other.

Your statement is quite complex - I recommend breaking it down in very small amounts. Join two tables to work, and then gradually add other tables inside.

No comments:

Post a Comment