hosted by liquidweb


Go Back   Web Hosting Talk : Web Hosting Main Forums : Programming Discussion : MySQL Query Troubleshoot
Reply

Programming Discussion Discussions related to web programming languages and other related issues. Topics may include configuration, optimization, practical usage and database connectivity.
Forum Jump

MySQL Query Troubleshoot

Reply Post New Thread In Programming Discussion Subscription
 
Send news tip View All Posts Thread Tools Search this Thread Display Modes
  #1  
Old 09-27-2011, 03:13 PM
RivaCom RivaCom is offline
Junior Guru Wannabe
 
Join Date: Mar 2005
Posts: 55

MySQL Query Troubleshoot


I'll try to explain this as best as possible. I have 3 tables(phpbb) I'm trying to pull 3 fields, from the 3 tables.

Table 1 -> user_id,username,rank_id
Table 2 -> rank_id,rank_title
Table 3 -> user_id, field1

Below is the query I use, I get the correct amount of users, but it stops input for field1 after the first field1 record. Not every entry will have a field 1 entry in the third table. So for example out of 25 entries, only 3 entries will have a entry in table3.

Code:
SELECT DISTINCT u.username, r.rank_title, IF(f.user_id = u.user_id, f.pf_field1, "")
FROM (phpbb_users u, phpbb_ranks r, phpbb_profile_fields_data f)
WHERE (u.user_rank BETWEEN "1" AND "6")
AND u.user_rank = r.rank_id
ORDER BY CASE r.rank_id
WHEN "2" THEN 1
WHEN "6" THEN 2
WHEN "4" THEN 3
WHEN "3" THEN 4
END
Any Ideas?

Reply With Quote


Sponsored Links
  #2  
Old 09-27-2011, 10:41 PM
foobic foobic is online now
Community Liaison 2.0
 
Join Date: Feb 2005
Location: Australia
Posts: 5,149
Have you tried using JOINs? From the description it sounds like you could get what you want with an inner join on table 2 and a left (outer) join on table 3.

__________________
Chris

"Learn from the mistakes of others. You can never live long enough to make them all yourself." - Groucho Marx

Reply With Quote
Reply

Similar Threads
Thread Thread Starter Forum Replies Last Post
Need Help with Mysql Query anastasia0181 Web Design and Content 2 05-20-2011 08:07 PM
MySQL Select Query - Selecing 2 tables with 1 query SmashedPumpkins Programming Discussion 2 04-22-2010 01:45 PM
mysql query jcroom Programming Discussion 2 07-19-2009 09:08 PM
Mysql query help Amish_Geek Programming Discussion 5 01-07-2006 02:35 PM
Help on mysql query kapot Programming Discussion 1 11-09-2003 05:07 AM

Related posts from TheWhir.com
Title Type Date Posted
New Relic, SOASTA Run Performance Management Tool on Cloud Testing Platform Web Hosting News 2012-05-24 16:32:42
Web Host Rackspace Launches Private Beta for MySQL Cloud Database Web Hosting News 2011-12-01 21:09:51
Parallels Now Offering Licenses for CloudLinux OS Web Hosting News 2011-10-26 17:29:25
Web Hosting Software Firm CloudLinux Releases CloudLinux OS Version 6.1 Web Hosting News 2011-09-13 14:08:49
Web Host FireHost Partners with Cloud Security Firm Gazzang for Data Encryption Web Hosting News 2011-08-16 20:33:43


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes
Postbit Selector

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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump
Login:
Log in with your username and password
Username:
Password:



Forgot Password?
Advertisement:
Web Hosting News:



 

X

Welcome to WebHostingTalk.com

Create your username to jump into the discussion!

WebHostingTalk.com is the largest, most influentual web hosting community on the Internet. Join us by filling in the form below.


(4 digit year)

Already a member?