MySQL linking plus updating questions?

  • jshaulis
  • Student
  • Student
  • No Avatar
  • Joined: May 05, 2004
  • Posts: 70
  • Status: Offline

Post June 15th, 2004, 11:37 am

Hello, I am pretty new at MySQL but here it goes,

I have 2 tables, one that has
$query="CREATE TABLE products (id int(6) NOT NULL auto_increment,fname varchar(15) NOT NULL,lname varchar(15) NOT NULL,stage2 varchar(20) NOT NULL,itemnumber varchar(20) NOT NULL,quanity varchar(20) NOT NULL,email varchar(30) NOT NULL,location varchar(30) NOT NULL,PRIMARY KEY (id),UNIQUE id (id),KEY id_2 (id))";

In the 2nd table I want to have 3 items, itemnumber, quanity, and descrition.
I want itemnumber from the 1st table to refer to the 2nd table and update the quanity. For example, If I order 3 of item #12345 then i want it to update the #12345 to 3. And then say in a week someone else orders 4 of #12345 then i want it to change to 7. How would I go about linking these tables together. Any help would be nice. Thanks in advance,

Justin
  • Anonymous
  • Bot
  • No Avatar
  • Joined: 25 Feb 2008
  • Posts: ?
  • Loc: Ozzuland
  • Status: Online

Post June 15th, 2004, 11:37 am

  • Tannu4u
  • Proficient
  • Proficient
  • User avatar
  • Joined: Apr 29, 2004
  • Posts: 480
  • Loc: India
  • Status: Offline

Post June 15th, 2004, 11:42 am

I think in the case of MySql u have to use ur coding language to do this.Everytime u have to read the corresponding entry from the second table and add the entry from the first table and then insert the result in the second table.u can make a function for this it will be easier for u to do this with a function.If u get any other answer then please post it here,Bye....
Amit
My Blog http://www.amityadav.name
  • jshaulis
  • Student
  • Student
  • No Avatar
  • Joined: May 05, 2004
  • Posts: 70
  • Status: Offline

Post June 15th, 2004, 11:45 am

Hello again,

I am using PHP for a lang... In all of the tutorals i have red, it says you have to link the tables together using a common term. This is really messing me up because none of them really go into detail of how to do this. I am confused, does this need to be done or not?

Post Information

  • Total Posts in this topic: 3 posts
  • Users browsing this forum: No registered users and 230 guests
  • You cannot post new topics in this forum
  • You cannot reply to topics in this forum
  • You cannot edit your posts in this forum
  • You cannot delete your posts in this forum
  • You cannot post attachments in this forum
 
 

© 2011 Unmelted, LLC. Ozzu® is a registered trademark of Unmelted, LLC.