Jump to content

mysql relational database problem, NEED HELP


MDanz

Recommended Posts

the following should return 1 row

 

$search= "Timothy";

$query4 = mysql_query("SELECT * FROM test1, test2, combination WHERE test1.IDONE = `combination`.IDONE AND test2.IDTWO = combination.IDTWO AND test1.NAME LIKE '%$search%'",$this->connect) or die(mysql_error());

 

 

instead it returns zero.

 

the query should take values from all three tables according to the where clause.

 

in short to describe the table structure.

 

3 tables(test1, test2, combination)

 

test1 has primary key IDONE, test2 has primary key IDTWO

 

combination looks like this

CREATE TABLE `combination` (
IDONE int( NOT NULL,
IDTWO varchar(11) NOT NULL,
INFO char(200) NOT NULL,

INDEX (IDONE, IDTWO),
PRIMARY KEY (IDONE,IDTWO),
FOREIGN KEY (IDTWO) REFERENCES `test2` (IDTWO)  ON UPDATE CASCADE ON DELETE CASCADE,
FOREIGN KEY (IDONE) REFERENCES `test1` (IDONE) ON UPDATE CASCADE ON DELETE CASCADE
) ENGINE=INNODB;

 

 

i havent done the relational database wrong.. there is no mysql_errors either. any idea?

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.