Webmaster Forums 101 - Free Help and Discussions
 
 
 

MEMBER REWARDS - Earn free advertising by participating in these forums! Click here for details.

Welcome to Webmaster Forums 101!

You are currently viewing our boards as a guest which gives you limited access to view most discussions, articles and access our other FREE features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload your own photos and access many other special features. Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact contact support.

Reply
 
Thread Tools Search this Thread Display Modes
Old 31st March 2005, 09:47 AM   #1

Username: Ben
Rank: WF101 Fanatic
Join Date: Jan 2005
Posts: 181
Points: 26.24
Thumbs up How do I select two tables from the same database?

Hey there,

I did a search and couldn't find anything.

I think I might have seen this before but can't remember...

If possible, how do I select from two tables in one database in the one query?

Eg:
Code:
select row from table1,table2

Thanks
Ben is offline   Reply With Quote
Old 12th April 2005, 11:25 AM   #2
Mr. Tech's Avatar

Username: Mr. Tech
Rank: Problem Solver
Join Date: Dec 2004
Location: Gold Coast, Australia
Posts: 2,166
Points: 1,025.61
Send a message via MSN to Mr. Tech
Default

Hey Ben,

Try this code:

PHP Code:
$query mysql_query("SELECT table1.field1, table2.field2 FROM database");
while(
$row mysql_fetch_array($query)) {
echo 
$row['field1'].' '.$row['field2'];


If the two fields have the same name then you'll need to tweak, but we'll get to that if that's the case. If you have a WHERE clause on the two fields then it can get icky and you might need to be careful.
__________________
Please read the Forum Rules

Get rewarded for posting
- free advertising!

.::. [ Webmaster Resources ] .::. [ Web Design ] .::. [ Developer Tutorials ] .::.
Mr. Tech is offline   Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
HTML: CSS vs Tables: What's the Difference? Mr. Tech Tutorials 3 8th February 2005 08:19 AM
HTML: Border Colors For Tables Mr. Tech Tutorials 0 17th January 2005 02:18 PM
Develop object oriented .NET database applications with TD smars The SPAM Box 0 4th May 2004 09:19 PM
New problem-div tables in NS - AAH jonDapron Website Design & Coding 1 20th December 2003 03:27 AM
Uploading Images into database with line of text. mr t Server-Side Scripting & Databases 1 17th November 2003 07:42 AM

Login
User Name
Password


Featured Members


Featured Links


Useful Resources
Webmaster Resources
Developers Tools
Developer Tutorials


Partners

All times are GMT +10. The time now is 09:01 AM.


Powered by vBulletin Version 3.5.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 2.3.2
 
 
WEBMASTER FORUMS 101
ARCHIVE
CONTACT US
TOP
   
© Webmaster Forums 101 2005. All Rights Reserved.
Design by: vBCore