473,466 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

Difficult JOIN?

TheServant
1,168 Recognized Expert Top Contributor
I have a difficult join situation which I am not quite sure on the SYNTAX or if it's even possible:
Expand|Select|Wrap|Line Numbers
  1. $raw_alliance_info = mysql_query(     "SELECT name, code, description, members, focus, bonus,
  2.                                     leader, sub, officer1, officer2, officer3
  3.                                     FROM alliances WHERE id='$alliance_id'");
This basically gets info from my "alliances table" but the problem is the leader, sub, officer1, officer2, officer3 columns.
These columns contain the user id who is in the role at the time. I want to get the user name for each by joining this table somehow with my users table (which contains each user's name).
Can it be done, or do I have to store usernames in the alliances table as well as their id's?
Mar 23 '09 #1
2 1718
code green
1,726 Recognized Expert Top Contributor
It looks possible but I may not fully understand. Something like
SELECT name, code, description, members, focus, bonus,
leader, sub, officer1, officer2, officer3
FROM alliances
JOIN users ON(`alliances`.`leader` = `users`.`leader`
OR alliances`.`sub` = `users`.`sub`
OR alliances`.`officer1` = `users`.`officer1`
OR alliances`.`officer2` = `users`.`officer2`
OR alliances`.`officer3 ` = `users`.`officer3`)
WHERE id='$alliance_id'
Mar 24 '09 #2
TheServant
1,168 Recognized Expert Top Contributor
Thanks for your reply. I will give it a go when I get home, but I have a feeling it is not really what I am after because it should really be ANDs nor ORs, but I don't think that will work. Maybe I let this one go and just double up a bit on data for simplcity sake.
Mar 25 '09 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Dave Pylatuk | last post by:
Hello all. I have a table defined in sql server as follows: ROW_ID (identity) DEPTH_FROM Number (8,3) DEPTH_TO Number (8,3) COLOUR Char(10) ...
6
by: lvpaul | last post by:
Hallo ! I have 2 tables with similar construction. DataOLD and DataNEW. In my grid I need a JOINED table. On the one hand I need all the data from the old table and the data from then...
4
by: d.p. | last post by:
Hi all, I'm using MS Access 2003. Bare with me on this description....here's the situation: Imagine insurance, and working out premiums for different insured properties. The rates for calculating...
1
by: mithril | last post by:
I cannot get my head around this query... I think I need a nested query but here's the problem. I promise i've exerted my meager brain power on this problem & ask this as a last resot! 3...
1
by: Claudio Magno | last post by:
Hi all, in short here it is my problem: I have to monitor the prices of a product sold by different shops and I need a query to retrieve a list of shops with the associated CURRENT price of the...
8
by: lvpaul | last post by:
Hello ! I habe 2 Tables Table1: Orders Fields: Ordernr, Opieces Table2: Calloffs Ordernr, Cpieces
1
by: pillbug | last post by:
I'm having trouble using bind1st with mem_fun1. I can't compile the line marked below with a @@. If I use the join2 method everything is fine, but I wind up passing string vectors by value. I...
4
by: n | last post by:
Hello! Here is a problem I hope you can point me to a solution. It Problem: A teacher needs to know which lesson to teach. A school has a curriculum with 26 lessons, A-Z. For a given class,...
4
by: =?iso-8859-1?B?VmFyZ2hq5HJ0YQ==?= | last post by:
Hi, I shall try to be short and to the point, this is a problem that no one IRL has yet been able to help me with thus far. Yet it feels as thought this is something that many people must tackle...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.