Database Help
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Codewalkers ForumsOther TechnologiesDatabase Help

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Codewalkers Forums Sponsor:
Dell PowerEdge Servers
  #1  
Old April 3rd, 2008, 12:40 PM
itsanogo itsanogo is offline
Registered User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Jun 2007
Posts: 8 itsanogo User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 7 m 30 sec
Reputation Power: 0
Need help with Mysql query

ok i have three tables

post table
-----------------
post_id --- category_id --- author_id -- content --- ect


categories table
-----------------
category_id --- category_name


users table
------
author_id --- username --- pw



whats the best way to query posts and fetch the related category_name and username with the post? how would i do it?

should i do three separate select queries? or is there a better way? performance wise

Reply With Quote
  #2  
Old April 4th, 2008, 09:44 PM
lig's Avatar
lig lig is offline
"Forum Nazi"
Codewalkers Demi-God (4500 - 4999 posts)
 
Join Date: Apr 2007
Location: Jacksonville, Fl
Posts: 4,719 lig User rank is Private First Class (20 - 50 Reputation Level)lig User rank is Private First Class (20 - 50 Reputation Level) 
Time spent in forums: 4 Days 4 m 29 sec
Reputation Power: 6
JOINs are a wonderful thing. See http://sqlcourse2.com/joins.html
__________________
life is a game.... Have fun
-----------------------------
http://www.phpwomen.org
strength in unity

PHPCommunity IRC
#phpc on freenode

Reply With Quote
  #3  
Old April 10th, 2008, 05:59 AM
leighrogers leighrogers is offline
Contributing User
Codewalkers Newbie (0 - 499 posts)
 
Join Date: Apr 2007
Posts: 41 leighrogers User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: 5 h 9 m 29 sec
Reputation Power: 2
Quote:
Originally Posted by itsanogo
ok i have three tables
post table
-----------------
post_id --- category_id --- author_id -- content --- ect

categories table
-----------------
category_id --- category_name

users table
------
author_id --- username --- pw



SELECT
post_id,
content,
category_name,
username

FROM
tbl_post,
tbl_category,
tbl_users

WHERE
tbl_post.category_id = tbl_category.category_id
AND
tbl_post.author_id = tbl_users.author_id..

Should do the trick....

Last edited by leighrogers : April 10th, 2008 at 06:00 AM. Reason: tidy up

Reply With Quote
Reply

Viewing: Codewalkers ForumsOther TechnologiesDatabase Help > Need help with Mysql query


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway