Select field from another table

K

Ken

Guest
Hi,

Thank you for providing such an excellent script. I tried to use the foreign_key_field to select a field from another table as you mentioned in your notes, but was not successful.

My question is: does the field need to be a foreign key to start with ? I use PHPMyAdmin to specify the SQL statement. I can't specify a foreign key in MySQL 3.23.32 table and their docunmentation discouraged such use.

When do you expect to release the multi-table option ? This will be an incredibly important upgrade for Dadabik in my mind. I can't seem to be able to sign up to your new email release alerts though.

Sincerely,
Ken
 
E

Eugenio

Guest
Ken wrote:

> Thank you for providing such an excellent script. I tried to
> use the foreign_key_field to select a field from another
> table as you mentioned in your notes, but was not successful.
>
> My question is: does the field need to be a foreign key to
> start with ? I use PHPMyAdmin to specify the SQL statement.
> I can't specify a foreign key in MySQL 3.23.32 table and
> their docunmentation discouraged such use.

Foreign key DaDaBIK feature doesn't depend on a foreign key feature of the MySQL DB, it simply provide a way to specify a list of options driving them from another table.

> When do you expect to release the multi-table option ?

In the next release.

>This
> will be an incredibly important upgrade for Dadabik in my
> mind. I can't seem to be able to sign up to your new email
> release alerts though.

The mailing list works fine, do you still have the same problem?

(Latest version of DaDaBIK when this message was posted: 1.8)
 
P

Peter

Guest
Hi,

I can't find any notes on the available settings to use on the internal tables table. Please can you point me to the URL?

Ken talks about the notes in his posting:
> Thank you for providing such an excellent script. I tried to
> use the foreign_key_field to select a field from another
> table as you mentioned in your notes, but was not successful.

I checked source-forge, google etc, but cant find a thing.

Thanks
Peter
 
N

Nestor

Guest
I have the same problem with the foreign_key_field to select a field from another table . Please any help will be appreciable
thanx
 
N

Nestor

Guest
Just to say that I am writting a select statement in the foreign_key_field. Is there any tutorial about using all the features of Dadabik.
Thanx
 
S

Sam

Guest
Easy way
-in the "foreign key field" put the table and field name where the lookup resides like this:
table.field

Advanced way
1. in the "Db name of the primary key" make sure that database exists (this is not a table name!)(leave empty if it is in this same database)
2. in the "foreign key field" use something like this:
SQL: select distinct foreign_key from master_table
3. in the "field_type" choose select_single
 
S

Sam

Guest
refinement--the order matters sometimes

SQL: select distinct foreign_key from master_table order by foreign_key
 
N

Norman Khine

Guest
Please someone advise me on this. In which filed do you add the foreign key field

Do you update it on the table that contains the Foreign Key, or is it on the table that has the Primary Key

I have the following two tables:

CREATE TABLE `BusinessName` (
`BusID` int(11) NOT NULL auto_increment,
`BusinessName` varchar(40) default NULL,
`Logo` blob,
`ImageOne` blob,
`ImageTwo` blob,
`ImageThree` blob,
`CompanyInfo` text,
`NoEmployees` int(11) default NULL,
`Turnover` int(11) default NULL,
`URL` varchar(35) default NULL,
`FK_MainBusID` int(11) NOT NULL default '0',
`Status` int(2) NOT NULL default '0',
PRIMARY KEY (`BusID`)
) TYPE=ISAM PACK_KEYS=1 AUTO_INCREMENT=150 ;


CREATE TABLE `BusinessAddress` (
`BusAddID` int(11) NOT NULL auto_increment,
`StreetName` varchar(25) default NULL,
`Town` varchar(25) default NULL,
`City` varchar(25) default NULL,
`State` varchar(40) default NULL,
`PostCode` varchar(10) default NULL,
`HomeOrBusiness` smallint(6) NOT NULL default '0',
`FK_CountyID` int(11) NOT NULL default '0',
`FK_CountryID` int(11) NOT NULL default '222',
`FK_BusID` int(11) NOT NULL default '0',
`FK_PostTownID` int(11) default NULL,
PRIMARY KEY (`BusAddID`)
) TYPE=ISAM PACK_KEYS=1 AUTO_INCREMENT=151 ;


So in my Insert form, if I want to have a select list for the BusinessName that the Address belongs to which field should I add the SQL to?

Cheers

Norman
 
S

Sam

Guest
in the FK_BusID field put "foreign key field" of "BusinessName.BusID"

 
E

Eugenio

Guest
Norman Khine wrote:

> Please someone advise me on this. In which filed do you add
> the foreign key field
>
> Do you update it on the table that contains the Foreign Key,
> or is it on the table that has the Primary Key
>
> I have the following two tables:

[....]

Duplicated post, see here:
http://www.dadabik.org/forum/read.php?f=1&i=1926&t=1926



(Latest version of DaDaBIK when this message was posted: 2.2.1)
 
M

Malehloa Jockey

Guest
I have
CREATE TABLE s
(
sno INT NOT NULL PRIMARY KEY,
name VARCHAR(10),
city VARCHAR(15)
) TYPE = INNODB;

CREATE TABLE p
(
pno INT NOT NULL PRIMARY KEY,
descr VARCHAR(10),
color CHAR(10)
) TYPE = INNODB;

CREATE TABLE sp
(
sno INT NOT NULL REFERENCES s,
pno INT NOT NULL REFERENCES P,
qty INT(5)
PRIMARY KEY(sno,pno)
) TYPE = INNODB;

INSERT INTO s VALUES(01,'Edgars','Maseru');
INSERT INTO p VALUES(201,'Shirt','Red');
INSERT INTO sp VALUES(01,201);
and this is ok.

What i don't understand is this
INSERT INTO SP VALUES(04,873);
query ok, one row affected.

WHY DOES IT ALLOW THIS VALUES YET THEY DO NOT APPEAR IN s and p tables.
 
M

Malehloa Jockey

Guest
I have
CREATE TABLE s
(
sno INT NOT NULL PRIMARY KEY,
name VARCHAR(10),
city VARCHAR(15)
) TYPE = INNODB;

CREATE TABLE p
(
pno INT NOT NULL PRIMARY KEY,
descr VARCHAR(10),
color CHAR(10)
) TYPE = INNODB;

CREATE TABLE sp
(
sno INT NOT NULL REFERENCES s,
pno INT NOT NULL REFERENCES P,
qty INT(5)
PRIMARY KEY(sno,pno)
) TYPE = INNODB;

INSERT INTO s VALUES(01,'Edgars','Maseru');
INSERT INTO p VALUES(201,'Shirt','Red');
INSERT INTO sp VALUES(01,201);
and this is ok.

What i don't understand is this
INSERT INTO SP VALUES(04,873);
query ok, one row affected.

WHY DOES IT ALLOW THIS VALUES YET THEY DO NOT APPEAR IN s and p tables.

 
E

Eugenio

Guest
Malehloa Jockey wrote:

[....]

> WHY DOES IT ALLOW THIS VALUES YET THEY DO NOT APPEAR IN s and
> p tables.

This is a MySQL-related question, not a DaDaBIK question, isn't it?

Bye,

Eugenio.

(Latest version of DaDaBIK when this message was posted: 3.2 beta)
 
Top