how can i create foreign key using qry?

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

how can i create foreign key using qry?

Post by itsmani1 »

Code: Select all

mysql_query("
create table jobs (
   jobid int(11) not null default '0',
   jobtitle varchar(255) not null,
   sdate date,
   edate date not null default '0000-00-00',
   experience varchar(255),
   salary int(11),
   `status` varchar(10) not null,
   primary key (jobid))
   type=MyISAM comment="";") or die(mysql_error());
in this way i wanted to create a foreign key in a table which will handel and manage thing ...
can i do so?
User avatar
AnarKy
Forum Contributor
Posts: 119
Joined: Tue Nov 02, 2004 1:49 am
Location: South Africa

SQL alter table.

Post by AnarKy »

Hi,

Use the ALTER TABLE SQL statement to add a foreign key.

Code: Select all

ALTER TABLE tbl_name ADD [CONSTRAINT symbol] FOREIGN KEY [index_name] (index_col_name,...)
User avatar
itsmani1
Forum Regular
Posts: 791
Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:

Re: SQL alter table.

Post by itsmani1 »

AnarKy wrote:Hi,

Use the ALTER TABLE SQL statement to add a foreign key.

Code: Select all

ALTER TABLE tbl_name ADD [CONSTRAINT symbol] FOREIGN KEY [index_name] (index_col_name,...)
can u plz. tell me what is [index_name] and [index_col_name]
i have one more question.
i never used @ sign in php and today i say this code which is using @ sign
can any one explain this to me.

Code: Select all

<?php
/* Intentional file error */
$my_file = @file('non_existent_file') or
   die ("Failed opening file: error was '$php_errormsg'");

// this works for any expression, not just functions:
$value = @$cache[$key]; 
// will not issue a notice if the index $key doesn't exist.

?>

Thanx
Post Reply