This topic is locked

Inner Join support & setup?

3/6/2007 3:03:17 PM
PHPRunner General questions
J
jace30025 author

Hello All

Evaluating what appears to be a fantastic product and I am having trouble creating a functional inner join from which one of the tables can be edited.
The DB is running on mysql v4.
I am attempting to create an updateable table view on table2 with table1 fields listed as reference only (will flag table1 fields as "read only" on the web page)
SELECT

table1.ID,

table1.field1,

table1.field2,

table1.field3,

table2.IDmatch,

table2.field1,

table2.field2,

table2.field3,

table2.field1+table2.field2+table2.field3 as total

FROM table2 INNER JOIN table1 ON

table1.ID=table2.IDmatch
After entering the sql manually I can't seem to define the primary key to table2 so it can be updated?
Any help would be greatly appreciated!

Alexey admin 3/7/2007

Jeff,
you need to include Table2 ID field into SQL query select list.

Also I recommend you to give aliases to all your joined fields.

I.e. use this query:

SELECT

table1.ID as t1ID,

table1.field1 as t1field1,

table1.field2 as t1field2,

table1.field3 as t1field3,

table2.ID,

table2.IDmatch,

table2.field1,

table2.field2,

table2.field3,

table2.field1+table2.field2+table2.field3 as total

FROM table2 INNER JOIN table1 ON

table1.ID=table2.IDmatch