Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > MySQL
|
MySQL General discussion about the MySQL database.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the MySQL section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old December 30th, 2009, 05:55 AM
Authorized User
 
Join Date: Sep 2003
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Greywacke
Question how to do a joined select from two tables? PLEASE HELP!

hi there,
i'm totally noob to mysql inner joins, but i need to know how do i select all the fields/columns and records in table a where a.someid = number1 AND a.anotherid = number2, and all the fields/columns where the records in table b match on a.thirdid = b.thirdid and a.anotherid = b.anotherid. i'm battling to discover which type of join i should use firstly, it seems a left join would work but no results are returned despite records being available in the respective tables.
here is the PMA response and the sql query i am trying to process in pma's sql editor for the database, i'm not really surprised as i am not at all sure which joins do what. i need all the columns in the returned result to have values, from this data it should be 2 records in the resultset.

Quote:
MySQL returned an empty result set (i.e. zero rows). ( Query took 0.0004 sec )
Code:
SELECT *
FROM 9_supplierattributes
LEFT JOIN 3_serviceattributes ON (3_serviceattributes.bigint_AttributeID = 9_supplierattributes.bigint_AttributeID
AND 3_serviceattributes.bigint_AttributeServiceID = 9_supplierattributes.bigint_ServiceID)
WHERE 9_supplierattributes.bigint_SupplierID = 1
AND 3_serviceattributes.bigint_AttributeServiceID = 1
the available records for these tables are:
Code:
9_supplierattributes
bigint_SupplierID | bigint_ServiceID | bigint_AttributeID | bigint_RegionID
6     1     1     7
6     1     2     7
Code:
3_serviceattributes
bigint_AttributeID | text_AttributeDescription | text_AttributeValue | bigint_AttributeServiceID
1     Test Attribute 1     Test Value 1     1
2     Test Attribute 1     Test Value 2     1
11     Test Attribute 1     Test Value 3     1
12     Test Attribute 2     Test Value 1     1
13     Test Attribute 2     Test Value 2     1
any help or even a nudge in the right direction will be greatly appreciated. :)
__________________
Sincerely,
Pierre "Greywacke" du Toit
pierre@greywacke.co.za
don't worry about my 0 thankyou's either way, i would say thank you should you help, and i will gladly help others when this work rush is over.

Last edited by Greywacke; December 30th, 2009 at 07:07 AM..
 
Old December 31st, 2009, 06:33 AM
Authorized User
 
Join Date: Sep 2003
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Greywacke
Talking

seems i do not need to use a LEFT JOIN for what i need, but rather a plain JOIN. this issue has been resolved.
__________________
Sincerely,
Pierre "Greywacke" du Toit
pierre@greywacke.co.za
don't worry about my 0 thankyou's either way, i would say thank you should you help, and i will gladly help others when this work rush is over.





Similar Threads
Thread Thread Starter Forum Replies Last Post
Listing results from joined tables henry-horse Classic ASP Basics 5 March 9th, 2007 07:08 AM
Select from Two Tables Problem gaurav_jain2403 SQL Server 2000 2 May 18th, 2006 07:18 AM
UPDATE with joined tables DanKent SQL Server 2000 4 July 6th, 2004 08:30 AM
Select lot tables... vieritlc Classic ASP Databases 3 May 18th, 2004 07:07 AM
inserting into joined tables cjennings SQL Server 2000 3 July 23rd, 2003 06:10 AM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.