Jump to content

MySQL UPDATE tables problem


plodos

Recommended Posts

MyDatabase

CREATE TABLE department (
   dept_id INT NOT NULL,
   dept_name TEXT,
   PRIMARY KEY (dept_id)
);

DROP TABLE IF EXISTS proficiency;

CREATE TABLE proficiency (
   p_id INT NOT NULL, 
   p_name TEXT NOT NULL,
   PRIMARY KEY (p_id)
);

DROP TABLE IF EXISTS doctor;

CREATE TABLE doctor (
   d_id INT NOT NULL PRIMARY KEY,
   d_name varchar(50) NOT NULL,
   d_surname VARCHAR(50) NOT NULL,
   d_add TEXT NOT NULL,
   SSN INT NOT NULL, 
   d_tel INT NOT NULL,
   d_bdate DATETIME NOT NULL,  # 2003-03-31 11:22:12
   p_id INT NOT NULL,          
   dept_id INT NOT NULL,
   FOREIGN KEY (dept_id) REFERENCES department (dept_id),
   FOREIGN KEY (p_id) REFERENCES proficiency (p_id)    
);

 

Problem is starting here

$_u ="UPDATE doctor dr, proficiency p, department d 
					SET  dr.d_name='$_d_name', 
					     dr.d_surname='$_d_surname', 
					     dr.d_add='$_d_add',
					     dr.SSN='$_SSN', 
					     dr.d_tel='$_d_tel', 
                                                     dr.d_bdate='$_d_bdate',
                                                    d.dept_name='$_dept_name',
                                                    p.p_name='$_p_name'
					WHERE dr.d_id ='$id' AND dr.dept_id = d.dept_id AND dr.p_id = p.p_id ;";

I want to UPDATE doctor departments and doctor informations, but i dont know how to write multiple querys.... how can I do that?

Link to comment
https://forums.phpfreaks.com/topic/106813-mysql-update-tables-problem/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.