RSS Forums RSS
Please support our MS SQL advertiser: Programming Forums
Views: 626 | Replies: 1
Reply
Join Date: Nov 2007
Posts: 128
Reputation: k2k is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
k2k k2k is offline Offline
Junior Poster

how to connect 2 tables?

  #1  
Sep 27th, 2008
I just started learning php and mySQL, if i want to create 2 tables, how do i connect them with a foreign key? In oracle, it is something like below, would any one point out what have to change to make it work in mySQL? phpMyadmin GUI doesn't seem like it needs a foreign key to connect a table. Please explain a bit and thanks very much.

create table customer(
cid INTEGER PRIMARY KEY NOT NULL AUTO_INCREMENT,
name VARCHAR(20));

CREATE TABLE order(
oid INTEGER PRIMARY KEY NOT NULL AUTO_INCREMENT,
o_date VARCHAR(10),
FOREIGN KEY(cid) REFERENCES customers);
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Feb 2007
Location: Bangalore,India
Posts: 1,455
Reputation: debasisdas is on a distinguished road 
Rep Power: 4
Solved Threads: 87
debasisdas's Avatar
debasisdas debasisdas is online now Online
Nearly a Posting Virtuoso

Re: how to connect 2 tables?

  #2  
Oct 5th, 2008
try this

foreignkey (oid) references customer(cid)

as part of the 2nd table creation.
Share your Knowledge.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 1:42 pm.
Newsletter Archive - Sitemap - Privacy Statement - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC