I'm using PHPR 4.1 with a MySQL database on a Linux server (haven't received the 4.2 key yet)
I'm trying to add a second inner join to a currently working query that already has an inner join.
I have 3 tables:
gallery (main table)
contact (joining 2 fields on the contact id (gallery.contact_id) field) already working and functioning in an uploaded build.
categories (joining 10 fields on the categories id (gallery.cat_id) field) PROBLEM
When I do the query of gallery with inner join on contact everything works perfectly using the following code:
[codebox]select
`gallery`.`id` as `id`,
`gallery`.`item_id` as `item_id`,
`gallery`.`name` as `name`,
`gallery`.`image_sm` as `image_sm`,
`gallery`.`image_lg` as `image_lg`,
`gallery`.`image_02` as `image_02`,
`gallery`.`image_03` as `image_03`,
`gallery`.`image_04` as `image_04`,
`gallery`.`subject` as `subject`,
`gallery`.`dimensions_metric` as `dimensions_metric`,
`gallery`.`dimensions_english` as `dimensions_english`,
`gallery`.`weight_kg` as `weight_kg`,
`gallery`.`weight_lb` as `weight_lb`,
`gallery`.`price` as `price`,
`gallery`.`price_reg` as `price_reg`,
`gallery`.`saletag` as `saletag`,
`gallery`.`price_sale` as `price_sale`,
`gallery`.`price_paypal` as `price_paypal`,
`gallery`.`retail_value` as `retail_value`,
`gallery`.`available` as `available`,
`gallery`.`sold` as `sold`,
`gallery`.`method` as `method`,
`gallery`.`material` as `material`,
`gallery`.`completion_time` as `completion_time`,
`gallery`.`stone_size` as `stone_size`,
`gallery`.`marble_thickness` as `marble_thickness`,
`gallery`.`background` as `background`,
`gallery`.`desc_short` as `desc_short`,
`gallery`.`desc_long` as `desc_long`,
`gallery`.`alt_text` as `alt_text`,
`gallery`.`status` as `status`,
`gallery`.`category` as `category`,
`gallery`.`cat_id` as `cat_id`,
`gallery`.`contact_id` as `contact_id`,
`contact`.`id` as `contact_joinid`,
`contact`.`paypal_email` as `paypal_email`,
`contact`.`ship_price_per_kg``gallery`.`weight_kg` as `ship_price`
From `gallery`
inner join `contact` on `contact`.`id` = `gallery`.`contact_id`
where category='1' and status='active'[/codebox]
My problem starts when I try to add the inner join on the categories table using the following code:
[codebox]select
`gallery`.`id` as `id`,
`gallery`.`item_id` as `item_id`,
`gallery`.`name` as `name`,
`gallery`.`image_sm` as `image_sm`,
`gallery`.`image_lg` as `image_lg`,
`gallery`.`image_02` as `image_02`,
`gallery`.`image_03` as `image_03`,
`gallery`.`image_04` as `image_04`,
`gallery`.`subject` as `subject`,
`gallery`.`dimensions_metric` as `dimensions_metric`,
`gallery`.`dimensions_english` as `dimensions_english`,
`gallery`.`weight_kg` as `weight_kg`,
`gallery`.`weight_lb` as `weight_lb`,
`gallery`.`price` as `price`,
`gallery`.`price_reg` as `price_reg`,
`gallery`.`saletag` as `saletag`,
`gallery`.`price_sale` as `price_sale`,
`gallery`.`price_paypal` as `price_paypal`,
`gallery`.`retail_value` as `retail_value`,
`gallery`.`available` as `available`,
`gallery`.`sold` as `sold`,
`gallery`.`method` as `method`,
`gallery`.`material` as `material`,
`gallery`.`completion_time` as `completion_time`,
`gallery`.`stone_size` as `stone_size`,
`gallery`.`marble_thickness` as `marble_thickness`,
`gallery`.`background` as `background`,
`gallery`.`desc_short` as `desc_short`,
`gallery`.`desc_long` as `desc_long`,
`gallery`.`alt_text` as `alt_text`,
`gallery`.`status` as `status`,
`gallery`.`category` as `category`,
`gallery`.`cat_id` as `cat_id`,
`categories`.`id` as `category_id`,
`categories`.`label_01` as `label_01`,
`categories`.`label_02` as `label_02`,
`categories`.`label_03` as `label_03`,
`categories`.`label_04` as `label_04`,
`categories`.`label_05` as `label_05`,
`categories`.`label_06` as `label_06`,
`categories`.`label_07` as `label_07`,
`categories`.`label_08` as `label_08`,
`categories`.`label_09` as `label_09`,
`categories`.`label_10` as `label_10`,
`gallery`.`contact_id` as `contact_id`,
`contact`.`id` as `contact_joinid`,
`contact`.`paypal_email` as `paypal_email`,
`contact`.`ship_price_per_kg``gallery`.`weight_kg` as `ship_price`
From `gallery`
inner join `contact` on `contact`.`id` = `gallery`.`contact_id`
inner join `categories` on `categories`.`id` = `gallery`.`cat_id`
where category='1' and status='active'[/codebox]
Where am I going wrong with my new query? I get an error in PHPR as soon as I add anything to do with the categories table.
This is the error:
"Your SQL query contains the following duplicate field names:
All fields in the query must have unique names or aliases.
Correct your SQL query or uncheck "Edit SQL Query manually" box.
I don't have any duplicate field names.
Any assistance would be appreciated ASAP.
Thanks!