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

Home Posts Topics Members FAQ

display two columns of data with lookup from another table

I'm trying to do a lookup from a table where an ID number equals a
name. But in selecting from three tables, I can't seem to figure out
how to display the data in the fashion I need.

In the first table (user_contact), I have contact info for each user
and the user ID. In the second table (user_info), each user ID will
have a primary genre, and an alternate genre (as an ID number). The
third table holds the lookup information for genre_id, and
genre_label.

Table user_contact:
+----------------+--------------+
| Field | Type |
+----------------+--------------+
| u_id | int(10) |
| u_name | varchar(50) |
+----------------+--------------+

Table user_info:
+----------------+--------------+
| Field | Type |
+----------------+--------------+
| u_id | int(10) |
| u_prim_genre | varchar(50) |
| u_alt_genre | varchar(50) |
+----------------+--------------+

Table genres:
+----------------+--------------+
| Field | Type |
+----------------+--------------+
| genre_id | int(10) |
| genre_label | varchar(50) |
+----------------+--------------+

What I'd like to see is a listing of each user with the label of their
primary and alternate genre listed. Something like this;

Table user_info:
+----------------+---------------------------------+
| User Name | Primary Genre | Alternate Genre |
+----------------+---------------------------------+
| User #1 | Rock | Hip-Hop |
| User #2 | Pop | Opera |
+----------------+---------------------------------+

I've tried the following, but with no success.
SELECT
u_name,u_prim_genre,u_alt_genre FROM user_contact,user_info
LEFT JOIN genres ON
(user_info.u_prim_genre = genres.genre_id and user_info.u_alt_genre =
genres.genre_id);

I'm thinking this involves the use of a join, but I'm not sure. Can
anyone offer any ideas?
Jul 19 '05 #1
0 2002

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Carl | last post by:
Hi, I have found a way to map attributes (columns) to column headings. But this runs really slow. Is there a way to improve it? Thanks, Carl <?xml version="1.0" encoding="utf-8" ?>...
8
by: Steve Jorgensen | last post by:
Hi folks, I'm posting this message because it's an issue I come up against relatively often, but I can't find any writings on the subject, and I haven't been able to figure out even what key...
1
by: Rich | last post by:
I have a form with a combo box on it. The combo box's source is a access lookup table with two columns, EmployeeName & EmployeeNumber. I want to display the EmployeeName from the dropdown but...
18
by: Alpha | last post by:
Hi, I'm working on a Windows applicaton with VS 2003 on windows 2000. I have a listbox that I have binded to a dataset table, "source" which has 3 columns. I would like to display 2 of those...
1
by: Mike | last post by:
How can I implement a Form which has a DataGrid displaying data from MS Access/SQL Table but instead of updating using the Data Grid I would like to be able to bring up a Form for Data Entry as...
3
by: jim.murphy | last post by:
I am not sure If I can do this with a lookup, but what I would like to do is perhaps use lookup to retrieve a control date from an unassociated table to control what date is entered in another...
1
by: Justin | last post by:
Hi all, I have a bunch of drop-down lists that should each display an item (from a SQL Server lookup table) based on another piece of data from a separate table. For example; If Not...
7
oll3i
by: oll3i | last post by:
i want to change the values in two columns one colum is a combobox and the secons column is editable too i want to get the value of that second column and the value of combobox and sent that...
2
by: J055 | last post by:
Hi I need to search a number of DataTables within a DataSet (with some relationships) and then display the filtered results in a GridView. The Columns that need to be displayed come from 2 of...
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
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
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: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.