[PHP-DB] Re: JOIN question

2004-07-28 Thread David Robley
On Wed, 28 Jul 2004 14:00, Chris Payne wrote:

 Hi there everyone,
 
  
 
 I'm transferring a client's product from a Visual Basic .NET ACCESS 2000
 application to run on a custom install of Apache/MySQL/PHP which I created
 (With a custom installer which sets everything up for them).
 
  
 
 My question though, is on looking through their ACCESS database, there
 seem to be table joins - or at least that's what I understand they would
 be under
 MySQL 4.  How can I read information from 3 tables at the same time?  I am
 a little confused, I gather you use JOIN but I'm not sure how it works,
 could someone please show me an easy to follow example?
 
  
 
 Thanks, I really appreciate it.
 
  
 
 Oh and so far, on the pages that I haven't had to use JOINS, I can
 honestly say that MySQL is FAR faster than ACCESS from what I'm seeing in
 my development here.
 
  
 
 Chris

Check out http://dev.mysql.com/doc/mysql/en/JOIN.html for the syntax and
examples, and also http://www.google.com/search?q=sql+tutorial as a
starting point for some SQL tutorials which will cover joins in more detail
than you will probably get here.


-- 
David Robley

Shh! Be vewy quiet, I'm hunting wuntime errors!

-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-DB] A Join Question

2001-07-30 Thread Steve Fitzgerald

I'm trying to create a join statement that pulls out a CompanyName based
on a given CompanyID that is tied to a specified ContactID.

For example, if ContactID=1 then the corresponding CompanyName might be
Smith, Inc. depending on what was entered.

Here are the tables.

table = Contacts

FIELD | TYPE | ATTRIBUTES | NULL | DEFAULT | EXTRA |


ContactID | INT(4) | UNSIGNEED | NO | AUTO_INCREMENT |  Primary
Key/Unique
CompanyID | INT(4) |


// more fields



table = Company

FIELD | TYPE | ATTRIBUTES | NULL | DEFAULT  | EXTRA |

CompanyID | INT(4) | UNSIGNEED | NO  | AUTO_INCREMENT |  Primary
Key/Unique
CompanyName | INT(4) |

//more fields

-

What I have tried so far is:

SELECT * FROM contacts,company WHERE contacts.CompanyID=$ContactID and
companyID= $ContactID

I've tried slightly other variations including:

SELECT CompanyName,WebSite
FROM $table_name1,$table_name2
WHERE contacts.CompanyID='$CompanyID'


also,

SELECT *
FROM Contacts,Company
WHERE
Contacts.CompanyID=Company.CompanyID AND
Contacts.CompanyID='$ContactID'

With this I get an empty set.


None of these seem to work. I'm obviously not doing the join right, but
I'm not sure what I'm leaving out.

Thanks.

Steve




-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]